private void SetThrustMountPoints(string subtypeId, params MyObjectBuilder_CubeBlockDefinition.MountPoint[] addMPObjects) { MyCubeBlockDefinition def; if (MyDefinitionManager.Static.TryGetCubeBlockDefinition(new MyDefinitionId(typeof(MyObjectBuilder_Thrust), MyStringHash.GetOrCompute(subtypeId)), out def)) { // HACK since there's no way to edit the flame properly, this hides it and the mod draws its own MyThrustDefinition thrustDef = (MyThrustDefinition)def; thrustDef.FlameFullColor = Vector4.Zero; thrustDef.FlameIdleColor = Vector4.Zero; MyCubeBlockDefinition.MountPoint[] mp = def.MountPoints; def.MountPoints = new MyCubeBlockDefinition.MountPoint[mp.Length + addMPObjects.Length]; for (int i = 0; i < mp.Length; i++) { def.MountPoints[i] = mp[i]; } for (int i = 0; i < addMPObjects.Length; ++i) { MyObjectBuilder_CubeBlockDefinition.MountPoint mpObj = addMPObjects[i]; Vector3 start = new Vector3(Vector2.Min(mpObj.Start, mpObj.End) + 0.001f, 0.0004f); Vector3 end = new Vector3(Vector2.Max(mpObj.Start, mpObj.End) - 0.001f, -0.0004f); int side = (int)mpObj.Side; TransformMountPointPosition(ref start, side, def.Size, out start); TransformMountPointPosition(ref end, side, def.Size, out end); Vector3I forward = Vector3I.Forward; Vector3I.TransformNormal(ref forward, ref m_mountPointTransforms[side], out forward); def.MountPoints[mp.Length + i] = new MyCubeBlockDefinition.MountPoint() { Start = start, End = end, Normal = forward, ExclusionMask = mpObj.ExclusionMask, PropertiesMask = mpObj.PropertiesMask, Enabled = mpObj.Enabled, Default = mpObj.Default, }; } } }
public MyObjectBuilder_CubeBlockDefinition.MountPoint GetObjectBuilder(Vector3I cubeSize) { MyObjectBuilder_CubeBlockDefinition.MountPoint ob = new MyObjectBuilder_CubeBlockDefinition.MountPoint(); ob.Side = NormalToBlockSide(Normal); Vector3 localStart; Vector3 localEnd; MyCubeBlockDefinition.UntransformMountPointPosition(ref Start, (int)ob.Side, cubeSize, out localStart); MyCubeBlockDefinition.UntransformMountPointPosition(ref End, (int)ob.Side, cubeSize, out localEnd); ob.Start = new SerializableVector2(localStart.X, localStart.Y); ob.End = new SerializableVector2(localEnd.X, localEnd.Y); ob.ExclusionMask = ExclusionMask; ob.PropertiesMask = PropertiesMask; return(ob); }
public override MyObjectBuilder_DefinitionBase GetObjectBuilder() { MyObjectBuilder_CubeBlockDefinition ob = (MyObjectBuilder_CubeBlockDefinition)base.GetObjectBuilder(); ob.Size = this.Size; ob.Model = this.Model; ob.UseModelIntersection = this.UseModelIntersection; ob.CubeSize = this.CubeSize; ob.ModelOffset = this.ModelOffset; ob.BlockTopology = this.BlockTopology; ob.PhysicsOption = this.PhysicsOption; ob.BlockPairName = this.BlockPairName; ob.Center = this.m_center; ob.MirroringX = this.m_symmetryX; ob.MirroringY = this.m_symmetryY; ob.MirroringZ = this.m_symmetryZ; ob.DeformationRatio = this.DeformationRatio; ob.EdgeType = this.EdgeType; ob.AutorotateMode = this.AutorotateMode; ob.MirroringBlock = this.m_mirroringBlock; ob.MultiBlock = this.MultiBlock; ob.GuiVisible = this.GuiVisible; ob.Rotation = this.Rotation; ob.Direction = this.Direction; ob.Mirrored = this.Mirrored; ob.BuildType = this.BuildType; ob.GeneratedBlockType = this.GeneratedBlockType.ToString(); ob.DamageEffectId = this.DamageEffectID.HasValue ? this.DamageEffectID.Value : 0; ob.CompoundTemplates = this.CompoundTemplates; ob.Icon = Icon; //ob.SubBlockDefinitions = SubBlockDefinitions; //ob.BlockVariants = BlockVariants; if (Components != null) { List <MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent> compObs = new List <MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent>(); foreach (var comp in Components) { var compOb = new MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent(); compOb.Count = (ushort)comp.Count; compOb.Type = comp.Definition.Id.TypeId; compOb.Subtype = comp.Definition.Id.SubtypeName; compObs.Add(compOb); } ob.Components = compObs.ToArray(); } ob.CriticalComponent = new MyObjectBuilder_CubeBlockDefinition.CriticalPart() { Index = 0, Subtype = ob.Components[0].Subtype, Type = ob.Components[0].Type }; List <MyObjectBuilder_CubeBlockDefinition.MountPoint> mountPoints = null; if (MountPoints != null) { mountPoints = new List <MyObjectBuilder_CubeBlockDefinition.MountPoint>(); foreach (var mountPoint in MountPoints) { MyObjectBuilder_CubeBlockDefinition.MountPoint mpOb = mountPoint.GetObjectBuilder(Size); mountPoints.Add(mpOb); } ob.MountPoints = mountPoints.ToArray(); } return(ob); }
public MyObjectBuilder_CubeBlockDefinition.MountPoint GetObjectBuilder(Vector3I cubeSize) { MyObjectBuilder_CubeBlockDefinition.MountPoint ob = new MyObjectBuilder_CubeBlockDefinition.MountPoint(); ob.Side = NormalToBlockSide(Normal); Vector3 localStart; Vector3 localEnd; MyCubeBlockDefinition.UntransformMountPointPosition(ref Start, (int)ob.Side, cubeSize, out localStart); MyCubeBlockDefinition.UntransformMountPointPosition(ref End, (int)ob.Side, cubeSize, out localEnd); ob.Start = new SerializableVector2(localStart.X, localStart.Y); ob.End = new SerializableVector2(localEnd.X, localEnd.Y); ob.ExclusionMask = ExclusionMask; ob.PropertiesMask = PropertiesMask; ob.Enabled = Enabled; return ob; }