/// <summary> /// Fired when entity is spawned. /// </summary> public override void OnSpawn() { Game game = Engine3D.Source as Game; Rend = new EntitySimple3DRenderableModelProperty() { EntityModel = game.Client.Models.Cylinder, Scale = new Location(0.1, 0.1, 1), DiffuseTexture = game.Client.Textures.White, Color = Color4F.Blue, IsVisible = false }; Entity.AddProperty(Rend); Entity.OnTick += Tick; }
/// <summary> /// Fired when entity is spawned. /// </summary> public override void OnSpawn() { Health = MaxHealth; Energy = MaxEnergy; Game game = Engine3D.Source as Game; double mul = 0.866 * Size; // Build the renderable property Renderable = new EntitySimple3DRenderableModelProperty() { EntityModel = game.Client.Models.Cylinder, Scale = new Location(mul, mul, 2 * Size), DiffuseTexture = game.Client.Textures.White, Color = Color4F.Blue }; // Build the physics body property Body = new ClientEntityPhysicsProperty() { Shape = new EntityCylinderShape() { FixedOrientation = true, Height = 2 * Size, Radius = 0.5 * Size }, Mass = 0 }; // Add properties and set position Entity.AddProperties(Renderable, Body); Vector2 pos = Coords.ToCartesianCoords2D(); Entity.SetPosition(new Location(pos.X, pos.Y, game.Terrain.HeightMap[Coords.U, Coords.V] + Size)); // Update the UnitFaces array with this unit's occupied faces foreach (GridFace face in game.UnitController.OccupiedFaces(Size, Coords)) { game.UnitFaces[face.U, face.V] = this; } Entity.OnTick += Tick; }