Ejemplo n.º 1
0
        protected override void Init(MyObjectBuilder_DefinitionBase objectBuilder)
        {
            var builder = (MyObjectBuilder_CharacterDefinition)objectBuilder;
            Name = builder.Name;
            Model = builder.Model;
            ReflectorTexture = builder.ReflectorTexture;
            LeftGlare = builder.LeftGlare;
            RightGlare = builder.RightGlare;
            LeftLightBone = builder.LeftLightBone;
            RightLightBone = builder.RightLightBone;
            LightGlareSize = builder.LightGlareSize;
            HeadBone = builder.HeadBone;
            Camera3rdBone = builder.Camera3rdBone;
            LeftHandIKStartBone = builder.LeftHandIKStartBone;
            LeftHandIKEndBone= builder.LeftHandIKEndBone;
            RightHandIKStartBone= builder.RightHandIKStartBone;
            RightHandIKEndBone= builder.RightHandIKEndBone;
            WeaponBone = builder.WeaponBone;
            LeftHandItemBone = builder.LeftHandItemBone;
            RighHandItemBone = builder.RightHandItemBone;
            Skeleton = builder.Skeleton;
            LeftForearmBone = builder.LeftForearmBone;
            LeftUpperarmBone = builder.LeftUpperarmBone;
            RightForearmBone = builder.RightForearmBone;
            RightUpperarmBone = builder.RightUpperarmBone;
            SpineBone = builder.SpineBone;
            BendMultiplier1st = builder.BendMultiplier1st;
            BendMultiplier3rd = builder.BendMultiplier3rd;
            MaterialsDisabledIn1st = builder.MaterialsDisabledIn1st;
			Stats = builder.Stats;
            FeetIKEnabled = builder.FeetIKEnabled;
            ModelRootBoneName = builder.ModelRootBoneName;
            LeftHipBoneName = builder.LeftHipBoneName;
            LeftKneeBoneName = builder.LeftKneeBoneName;
            LeftAnkleBoneName = builder.LeftAnkleBoneName;
            RightHipBoneName = builder.RightHipBoneName;
            RightKneeBoneName = builder.RightKneeBoneName;
            RightAnkleBoneName = builder.RightAnkleBoneName;     
            NeedsOxygen = builder.NeedsOxygen;
            OxygenConsumption = builder.OxygenConsumption;
            PressureLevelForLowDamage = builder.PressureLevelForLowDamage;
            DamageAmountAtZeroPressure = builder.DamageAmountAtZeroPressure;
            RagdollDataFile = builder.RagdollDataFile;
            HelmetVariation = builder.HelmetVariation;
            DeathSoundName = builder.DeathSoundName;
            VisibleOnHud = builder.VisibleOnHud;
            RagdollRootBody = builder.RagdollRootBody;


            FeetIKSettings = new Dictionary<MyCharacterMovementEnum,MyFeetIKSettings>();
            if (builder.IKSettings != null)
            {
                foreach (var feetSettings in builder.IKSettings)
                {
                    
                    string[] states = feetSettings.MovementState.Split(',');
                    
                    foreach (string stateSet in states) 
                    {
                        string stateDef = stateSet.Trim();
                        if (stateDef != "")
                        {
                            Debug.Assert(Enum.GetNames(typeof(MyCharacterMovementEnum)).Contains(stateDef), "State " + stateDef + " is not defined in Character Movement States");
                            MyCharacterMovementEnum state;
                            if (Enum.TryParse(stateDef, true, out state))
                            {
                                MyFeetIKSettings fSettings = new MyFeetIKSettings();
                                fSettings.Enabled = feetSettings.Enabled;
                                fSettings.AboveReachableDistance = feetSettings.AboveReachableDistance;
                                fSettings.BelowReachableDistance = feetSettings.BelowReachableDistance;
                                fSettings.VerticalShiftDownGain = feetSettings.VerticalShiftDownGain;
                                fSettings.VerticalShiftUpGain = feetSettings.VerticalShiftUpGain;
                                fSettings.FootSize = new Vector3(feetSettings.FootWidth, feetSettings.AnkleHeight, feetSettings.FootLenght);
                                FeetIKSettings.Add(state, fSettings);
                            }
                        }
                    }
                }
            }

            JetpackAvailable = builder.JetpackAvailable;
            JetpackSlowdown = builder.JetpackSlowdown;
            if (builder.Thrusts != null)
                Thrusts = builder.Thrusts;
            if (builder.BoneSets != null)
            {
                BoneSets = builder.BoneSets.ToDictionary(x => x.Name, x => x.Bones.Split(' '));
            }

            if (builder.AnimationMappings != null)
            {
                AnimationNameToSubtypeName = builder.AnimationMappings.ToDictionary(mapping => mapping.Name, mapping => mapping.AnimationSubtypeName);
            }

            if (builder.RagdollBonesMappings != null)
            {
                RagdollBonesMappings = builder.RagdollBonesMappings.ToDictionary(x => x.Name, x => x.Bones.Split(' '));
            }

            if (builder.RagdollPartialSimulations != null)
            {
                RagdollPartialSimulations = builder.RagdollPartialSimulations.ToDictionary(x => x.Name, x => x.Bones.Split(' '));
            }

            Mass = builder.Mass;
            MaxHealth = builder.MaxHealth;
            OxygenCapacity = builder.OxygenCapacity;

            VerticalPositionFlyingOnly = builder.VerticalPositionFlyingOnly;
            UseOnlyWalking = builder.UseOnlyWalking;
                
            MaxSlope = builder.MaxSlope;
            MaxSprintSpeed = builder.MaxSprintSpeed;
            
            MaxRunSpeed = builder.MaxRunSpeed;
            MaxBackrunSpeed = builder.MaxBackrunSpeed;
            MaxRunStrafingSpeed = builder.MaxRunStrafingSpeed;
            
            MaxWalkSpeed = builder.MaxWalkSpeed;
            MaxBackwalkSpeed = builder.MaxBackwalkSpeed;
            MaxWalkStrafingSpeed = builder.MaxWalkStrafingSpeed;
            
            MaxCrouchWalkSpeed = builder.MaxCrouchWalkSpeed;
            MaxCrouchBackwalkSpeed = builder.MaxCrouchBackwalkSpeed;
            MaxCrouchStrafingSpeed = builder.MaxCrouchStrafingSpeed;
            
            CharacterHeadSize = builder.CharacterHeadSize;
            CharacterHeadHeight = builder.CharacterHeadHeight;
            CharacterCollisionScale = builder.CharacterCollisionScale;

            CharacterWidth = builder.CharacterWidth;
            CharacterHeight = builder.CharacterHeight;
            CharacterLength = builder.CharacterLength;

            if (builder.Inventory == null)
            {
                InventoryDefinition = new MyObjectBuilder_InventoryDefinition();
            }           
            else
            {
                InventoryDefinition = builder.Inventory;
            }

            EnabledComponents = builder.EnabledComponents.Split(' ').ToList();

            EnableSpawnInventoryAsContainer = builder.EnableSpawnInventoryAsContainer;        
            if (EnableSpawnInventoryAsContainer)
            {
                Debug.Assert(builder.InventorySpawnContainerId.HasValue, "Enabled spawning inventory as container, but type id is null");
                if (builder.InventorySpawnContainerId.HasValue)
                {
                    InventorySpawnContainerId = builder.InventorySpawnContainerId.Value;
                }
            }
        }
Ejemplo n.º 2
0
 public MyInventory(MyObjectBuilder_InventoryDefinition definition, MyInventoryFlags flags, IMyInventoryOwner owner)
     : this(definition.InventoryVolume, definition.InventoryMass, new Vector3(definition.InventorySizeX, definition.InventorySizeY, definition.InventorySizeZ), flags, owner)
 {
     myObjectBuilder_InventoryDefinition = definition;
 }