I'm trying the following code. When I middle-click, it creates a warrior at pick position and assigns its "canSelect" key to "true". When I click, it checks the "canSelect" entity of the key to know if it is selectable. However, that key checking always returns the default value (a.k.a. empty string), as if the model didn't keep its keys through the raycast.
Note: It's C#, but the syntax is very readable, so I assume you can all read it.
using System;
using System.Collections.Generic;
using Aerora.Logic;
using Leadwerks;
namespace Aerora
{
static class Client
{
public static bool Run = true;
private static Entity selected;
private static Entity Selected
{
get
{
return selected;
}
set
{
if (Selected != null)
{
Selected.Color = Color.White;
}
selected = value;
Selected.Color = Color.Red;
}
}
public static void Main(string[] args)
{
Engine.Initialize(DisplayMode.Window);
Framework.Initialize();
Filtering.Optimize();
FileSystem.Initialize(@"C:\Program Files\Aerora");
Framework.Effects.Bloom.Enabled = true;
Framework.Effects.VolumetricLighting.Enabled = true;
Framework.StatisticMode = StatisticMode.FrameRate;
Scene scene = new Scene("abstract::Dust Valley.sbx", Framework.Camera);
Explorer explorer = new Explorer(Framework.Camera);
Random r = new Random();
List<Model> warriors = new List<Model>();
while (Client.Run && !Window.HasRequestedClose)
{
explorer.Update();
Pick pick = new Pick(Framework.Camera, Mouse.X, Mouse.Y, 5000);
if (Mouse.ButtonHit(MouseButton.Middle))
{
Model warrior = new Model("abstract::warrior_character_skin.gmf")
{
Position = pick.Position,
ViewRange = ViewRange.Infinite,
Scale = 0.3f,
Rotation = new Vector3(0, r.Next(), 0)
};
warrior.Keys["canSelect"] = "true";
//pick.Entity.Keys["canSelect"] == "true"; // Returns true.
warriors.Add(warrior);
}
else if (Mouse.ButtonHit(MouseButton.Left))
{
if (pick.Entity.Keys["canSelect"] == "true") // Returns false.
{
Selected = pick.Entity;
}
}
foreach (Model warrior in warriors)
{
warrior.Animate(Timing.Time / 20);
}
Timing.Update();
Framework.Update();
Framework.Render();
Graphics.Flip();
}
Framework.Terminate();
Engine.Terminate();
}
}
}