### Define SpriteComponent Layers Source: https://github.com/space-wizards/robusttoolbox/wiki/Sprite-&-Icon-documentation Example of defining multiple rendering layers within a SpriteComponent prototype. ```yml - type: sprite layers: - texture: "a.png" - texture: "b.png" - ... ``` -------------------------------- ### Parenting Controls in C# Source: https://github.com/space-wizards/robusttoolbox/wiki/UI-System-Tutorial Demonstrates how to instantiate Control objects and establish a parent-child relationship using the AddChild method. ```cs var parent = new Control("parent"); var child = new Control("child"); parent.AddChild(child); DebugTools.Assert(child.Parent == parent); ``` -------------------------------- ### Registering a Dependency Source: https://github.com/space-wizards/robusttoolbox/wiki/IoC-(Inversion-of-Control) Define an interface and its concrete implementation, then register them using IoCManager.Register during application startup. ```csharp // SS14.Server/Example/MyDependency.cs namespace SS14.Server.Example { public class MyDependency : IMyDependency { public void Foo() { Console.WriteLine("Hello World!"); } } } // SS14.Server/Interfaces/Example/IMyDependency.cs namespace SS14.Server.Interfaces.Example { public interface IMyDependency { /// /// Writes a message to the console. /// void Foo(); } } // SS14.Server/Program.cs AND SS14.UnitTesting/SS14UnitTest.cs, inside RegisterIoC() IoCManager.Register(); ``` -------------------------------- ### Using Field Injection Source: https://github.com/space-wizards/robusttoolbox/wiki/IoC-(Inversion-of-Control) Inject dependencies automatically into fields marked with the [Dependency] attribute and use IPostInjectInit for post-injection logic. ```csharp public class MyDependency : IMyDependency, IPostInjectInit { [Dependency] private readonly ILogger logger; // Gets called when logger becomes available. public void PostInject() { logger.info("MyDependency being created!"); // IMPORTANT: Don't actually do this specific thing with a logger. It gets the point across but is broken. // Because logger won't have been initialized properly yet, it has no output file. // As such, this message will go to the console, but will not be logged to any files. This is a bug. } public void Foo() { // This is fine of course, provided `Foo()` gets called after `BaseServer` had its way setting things up. logger.info("Hi!"); Console.WriteLine("Hello World!"); } } ``` -------------------------------- ### Define Texture Load Parameters in YAML Source: https://github.com/space-wizards/robusttoolbox/wiki/Texture-Load-Parameters Create a .yml file with the same name as the target PNG to specify sampling parameters like filtering and wrapping. ```yaml sample: # Sampling parameters. filter: true or false wrap: none, repeat or mirrored_repeat ``` -------------------------------- ### Define a Server-Side Component Source: https://github.com/space-wizards/robusttoolbox/wiki/Entity-and-Component-netcode Create a component class inheriting from Component, specifying a unique NetID and the properties to be replicated. ```csharp // NOTE: This specific snippet is server-side code. For this tutorial we'll assume the components are basically copies of each other. // Though when client or server-specific code is used it is marked. using SS14.Shared.GameObjects; using SS14.Shared.GameObjects.Components; namespace SS14.Server.GameObjects { public class DooHickyComponent : Component { // Name, needed by all components. public override string Name => "DooHicky"; // Net ID, required to sync across the network. // IMPORTANT: the type is uint?, NOT uint. The question mark means it's nullable. public override uint? NetID => NetIDs.DOO_HICKY; // The variable that we will be replicating. public bool DoTheStuff { get; set; } } } ``` -------------------------------- ### Implement Server-Side State Creation Source: https://github.com/space-wizards/robusttoolbox/wiki/Entity-and-Component-netcode Override GetComponentState on the server to return the current state of the component. ```csharp // SERVER SIDE CODE. public override ComponentState GetComponentState() { return new DooHickyComponentState(DoTheStuff); } ``` -------------------------------- ### Implement Client-Side State Handling Source: https://github.com/space-wizards/robusttoolbox/wiki/Entity-and-Component-netcode Define the expected state type and implement HandleComponentState to update the client component with received data. ```csharp // CLIENT SIDE CODE. public override Type StateType => typeof(DooHickyComponentState); public override void HandleComponentState(ComponentState state) { // Note: although the state is passed in as ComponentState, // It will always be the same type as StateType, you can safely cast it. var dooHickyState = (DooHickyComponentState)state; DoTheStuff = dooHickyState.DoTheStuff; } ``` -------------------------------- ### Define IconComponent in Prototype Source: https://github.com/space-wizards/robusttoolbox/wiki/Sprite-&-Icon-documentation Basic structure for an IconComponent prototype using either a direct texture or an RSI state. ```yml - type: icon texture: "" sprite: "" state: "" ``` -------------------------------- ### Define a Component State Source: https://github.com/space-wizards/robusttoolbox/wiki/Entity-and-Component-netcode Create a serializable class inheriting from ComponentState to hold the data being synchronized. ```csharp [Serializable] public class DooHickyComponentState : ComponentState { public bool DoTheStuff { get; set; } public DooHickyComponentState(bool doTheStuff) : base(NetIDs.DOO_HICKY) { DoTheStuff = doTheStuff; } } ``` -------------------------------- ### Define a replicated component with a NetID Source: https://github.com/space-wizards/robusttoolbox/wiki/Entity-and-Component-netcode Assign a unique NetID to a component to enable network synchronization. Use constants defined in NetIDs.cs for these identifiers. ```csharp public class DooHickyComponent : IComponent { public override string Name => "DooHicky"; public override uint NetID => NetIDs.DOO_HICKY; // ... } ``` -------------------------------- ### Register a Net ID Source: https://github.com/space-wizards/robusttoolbox/wiki/Entity-and-Component-netcode Add the new component's unique identifier to the NetIDs registry. ```csharp // ... public const uint WEARABLE_ANIMATED_SPRITE = 19; public const uint TRIGGERABLE = 20; // Our guy public const uint DOO_HICKY = 21; } } ``` -------------------------------- ### Update XAML Style Class Syntax Source: https://github.com/space-wizards/robusttoolbox/blob/master/RELEASE-NOTES.md The syntax for defining multiple style classes in XAML has been updated from a collection-based approach to a space-separated string attribute. ```xaml Hello World ``` ```xaml ``` -------------------------------- ### Resolving a Dependency Manually Source: https://github.com/space-wizards/robusttoolbox/wiki/IoC-(Inversion-of-Control) Retrieve a registered dependency instance using the IoCManager.Resolve method. ```csharp public class MyDependency : IMyDependency { public void Foo() { ILogger logger = IoCManager.Resolve(); logger.info("Hi!"); Console.WriteLine("Hello World!"); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.