/// <summary> /// For ribbons! /// </summary> /// <param name="lthing">The Thing this component is attached to</param> /// <param name="template">The template from the Thing</param> /// <param name="block">The block we're creating this component from</param> public RibbonComponent(LThing lthing, ThingBlock template, RibbonBlock block) { ID = IDs.Incremental; var sceneMgr = LKernel.GetG<SceneManager>(); Name = block.GetStringProperty("name", template.ThingName); // if ribbons are disabled, don't bother creating anything if (!Options.GetBool("Ribbons")) return; Ribbon = LKernel.GetG<SceneManager>().CreateRibbonTrail(Name + ID + "Ribbon"); // set up some properties Ribbon.SetMaterialName(block.GetStringProperty("material", "ribbon")); Ribbon.TrailLength = block.GetFloatProperty("length", 5f); Ribbon.MaxChainElements = (uint) block.GetFloatProperty("elements", 10f); Ribbon.SetInitialWidth(0, block.GetFloatProperty("width", 1f)); Ribbon.SetInitialColour(0, block.GetQuatProperty("colour", new Quaternion(1, 1, 1, 1)).ToColourValue()); Ribbon.SetColourChange(0, block.GetQuatProperty("colourchange", new Quaternion(0, 0, 0, 3)).ToColourValue()); Ribbon.SetWidthChange(0, block.GetFloatProperty("widthchange", 1f)); // attach it to the node RibbonNode = LKernel.GetG<SceneManager>().RootSceneNode.CreateChildSceneNode(Name + ID + "RibbonNode"); TrackedRibbonNode = lthing.RootNode.CreateChildSceneNode(Name + ID + "TrackedRibbonNode"); Ribbon.AddNode(TrackedRibbonNode); RibbonNode.AttachObject(Ribbon); TrackedRibbonNode.Position = block.GetVectorProperty("position", null); }
/// <summary> /// Ribbon blocks /// </summary> void ParseRibbon(ThingDefinition thingDef, RuleInstance block) { RibbonBlock ribbonBlock = new RibbonBlock(thingDef); for (int a = 2; a < block.Children.Length - 1; a++) { RuleInstance rule = block.Children[a] as RuleInstance; if (rule.Type == NodeType.Rule_Property) ParseProperty(ribbonBlock, rule.Children[0] as RuleInstance); } thingDef.RibbonBlocks.Add(ribbonBlock); }