Ejemplo n.º 1
0
        /// <summary>
        /// For physics
        /// </summary>
        /// <param name="lthing">The Thing this component is attached to</param>
        /// <param name="block">The block we're creating this component from</param>
        public ShapeComponent(LThing lthing, ShapeBlock block)
        {
            var sceneMgr = LKernel.GetG<SceneManager>();

            Transform = block.Transform;

            Type = block.GetEnumProperty("type", null);
            switch (Type) {
                case ThingEnum.Box:
                case ThingEnum.Cylinder:
                    Dimensions = block.GetVectorProperty("dimensions", null) / 2f;
                    break;
                case ThingEnum.Capsule:
                case ThingEnum.Cone:
                    Height = block.GetFloatProperty("height", null);
                    Radius = block.GetFloatProperty("radius", null);
                    break;
                case ThingEnum.Sphere:
                    Radius = block.GetFloatProperty("radius", null);
                    break;
                case ThingEnum.Heightmap:
                    MinHeight = block.GetFloatProperty("MinHeight", null);
                    MaxHeight = block.GetFloatProperty("MaxHeight", null);
                    Width = (int) block.GetFloatProperty("Width", null);
                    Length = (int) block.GetFloatProperty("Length", null);
                    Mesh = block.GetStringProperty("mesh", null);
                    Dimensions = block.GetVectorProperty("dimensions", null) / 2f;
                    break;
                case ThingEnum.Hull:
                case ThingEnum.Mesh:
                    Mesh = block.GetStringProperty("mesh", null);
                    break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Shape blocks
        /// </summary>
        void ParseShape(ThingDefinition thingDef, RuleInstance block)
        {
            ShapeBlock shapeBlock = new ShapeBlock(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(shapeBlock, rule.Children[0] as RuleInstance);
            }

            thingDef.ShapeBlocks.Add(shapeBlock);
        }