public static void CreateObjectAtMousePosition(MetaDataType metaDataType) { var realPosition = SimulationGame.RealWorldMousePosition; if (metaDataType is BlockType) { var blockPosition = GeometryUtils.GetBlockFromReal((int)realPosition.X, (int)realPosition.Y); var blockType = (BlockType)metaDataType; SimulationGame.World.SetBlockType(blockPosition.X, blockPosition.Y, SimulationGame.Player.InteriorID, blockType.ID); } else { if (!SimulationGame.KeyboardState.IsKeyDown(Keys.LeftControl) && !SimulationGame.KeyboardState.IsKeyDown(Keys.RightControl)) { var blockPosition = GeometryUtils.GetChunkPosition((int)realPosition.X, (int)realPosition.Y, 16, 16); realPosition = new Vector2(blockPosition.X * 16, blockPosition.Y * 16); } var newWorldPosition = new WorldPosition(realPosition.X, realPosition.Y, SimulationGame.Player.InteriorID); GameObject gameObject = null; if (metaDataType is AmbientObjectType) { gameObject = AmbientObjectType.Create(newWorldPosition, (AmbientObjectType)metaDataType); } else if (metaDataType is AmbientHitableObjectType) { gameObject = AmbientHitableObjectType.Create(newWorldPosition, (AmbientHitableObjectType)metaDataType); } else if (metaDataType is LivingEntityType) { gameObject = LivingEntityType.Create(newWorldPosition, (LivingEntityType)metaDataType); } gameObject.ConnectToWorld(); } }
public static AmbientObject createSmallRocks(WorldPosition position) { return(AmbientObjectType.Create(new WorldPosition(position.X - 12.5f + WorldGrid.BlockSize.X / 2, position.Y + 10 + WorldGrid.BlockSize.Y / 2, position.InteriorID), AmbientObjectType.lookup[random.Next(0, 2)])); }