public override void CreateCosmeticChildren(ComponentManager manager) { base.CreateCosmeticChildren(manager); if (Resource.Gui_Graphic != null) { var sheetName = Resource.Gui_Graphic.GetSheetIdentifier(); var tiledInstanceGroup = Manager.World.Renderer.InstanceRenderer.GetCombinedTiledInstance(); Texture2D fixedTex = null; if (!tiledInstanceGroup.DoesInstanceSheetExist(sheetName)) { fixedTex = ResourceGraphicsHelper.GetResourceTexture(manager.World.Renderer.GraphicsDevice, Resource.Gui_Graphic); } var sheet = new SpriteSheet(fixedTex) // The tiled instance renderer will automatically grab the texture from this. { FrameWidth = Resource.Gui_Graphic.FrameSize.X, FrameHeight = Resource.Gui_Graphic.FrameSize.Y, AssetName = sheetName }; var sprite = AddChild(new SimpleBobber(Manager, "Sprite", Matrix.CreateTranslation(Vector3.UnitY * 0.25f), sheet, Point.Zero, 0.15f, MathFunctions.Rand() + 2.0f, MathFunctions.Rand() * 3.0f) { OrientationType = SimpleSprite.OrientMode.Spherical, WorldHeight = 0.75f, WorldWidth = 0.75f, }) as Tinter; sprite.LocalTransform = Matrix.CreateTranslation(Vector3.UnitY * 0.25f + MathFunctions.RandVector3Cube() * 0.1f); sprite.LightRamp = new Color(255, 255, 255, 255); sprite.SetFlag(Flag.ShouldSerialize, false); } }
public static Gui.TextureAtlas.SpriteAtlasEntry GetDynamicSheet(Gui.Root Root, ResourceType.GuiGraphic Graphic) { var sheetName = Graphic.GetSheetIdentifier(); var tex = ResourceGraphicsHelper.GetResourceTexture(Root.RenderData.Device, Graphic); return(Root.SpriteAtlas.AddDynamicSheet(sheetName, new TileSheetDefinition { TileHeight = Graphic.FrameSize.Y, TileWidth = Graphic.FrameSize.X, Type = TileSheetType.TileSheet }, tex)); }
public static Gui.TextureAtlas.SpriteAtlasEntry GetDynamicSheet(Gui.Root Root, ResourceType.GuiGraphic Graphic) { if (Graphic == null) { var tex = AssetManager.GetContentTexture("newgui/error"); return(Root.SpriteAtlas.AddDynamicSheet("error", new TileSheetDefinition { TileHeight = 32, TileWidth = 32, Type = TileSheetType.TileSheet }, tex)); } else { var sheetName = Graphic.GetSheetIdentifier(); var tex = ResourceGraphicsHelper.GetResourceTexture(Root.RenderData.Device, Graphic); return(Root.SpriteAtlas.AddDynamicSheet(sheetName, new TileSheetDefinition { TileHeight = Graphic.FrameSize.Y, TileWidth = Graphic.FrameSize.X, Type = TileSheetType.TileSheet }, tex)); } }