public void ExplicitComponentDerived() { Dec.Config.TestParameters = new Dec.Config.UnitTestParameters { explicitStaticRefs = new System.Type[] { typeof(EntityTemplateDecs) } }; var parser = new Dec.Parser(); parser.AddString(@" <Decs> <ComponentDec decName=""EntityComponent""> <type>SimpleComponent</type> </ComponentDec> <EntityDec decName=""EntityModel""> <components> <li>EntityComponent</li> </components> </EntityDec> </Decs> "); parser.Finish(); Environment.Startup(); var comp = new DerivedComponent(); var entity = new Entity(EntityTemplateDecs.EntityModel, comp); Assert.AreSame(comp, entity.Component <SimpleComponent>()); }
public static void Execute() { var entity = new Entity(EntityTemplateDecs.EntityModel); Environment.Add(entity); // We intentionally add it first; we should still be able to muck with it entity.Component <SimpleComponent>().number = 4; }
public override void Initialize() { Entity.Component(new Kinematics()); Entity.Component(new Sprite(TextureManager.Load(Type))); Entity.Component ( new Render(Entity.Component <Sprite>(), Entity.Component <Kinematics>()) ); Entity.Component <Sprite>().Origin = Entity.Component <Sprite>().Size / 2; base.Initialize(); }
public virtual void Draw(SpriteBatch spriteBatch) { Entity.Component <Render>().Draw(spriteBatch); }
public AI(Entity e) { entity = e; entity.ai = this; entity.Component<AIController>(true).ai = this; }
public static void Execute(Entity entity) { ++Executions; Assert.IsNotNull(entity.Component <SimpleComponent>()); }
public List<Fish> SpawnFish(Entity fluid) { List<Fish> fishes = new List<Fish>(); Vector3 scale = fluid.Scale(); float volume = scale.x * scale.y * scale.z; float density = 1.5f / 125000f; float max = 100; float num = Mathf.Min(volume * density, max) * Random.value; for (int i = 1; i <= num; i++) { Vector3 offset = Vector3.Scale(Util.RandomVector(), scale/2); Vector3 pos = fluid.Position() + offset; float sizeMin = 0.5f; float sizeMax = Mathf.Pow(volume, 0.25f); float x = Random.value; float y = Random.value; Vector3 size = (sizeMin + 1f / (1f/sizeMax + x*y)) * Util.RandomVector(1f, 1.5f); Fish fish = new Fish(pos, size); fish.currentFluid = fluid.Component<Fluid>(); fishes.Add(fish); } return fishes; }