private void characterMovementStateCombo_ItemSelected()
        {
            MyCharacter playerCharacter = MySession.Static.LocalCharacter;

            MyCharacterMovementEnum selected = (MyCharacterMovementEnum)characterMovementStateCombo.GetSelectedKey();

            MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_MOVEMENT_STATE = selected;

            if (!playerCharacter.Definition.FeetIKSettings.TryGetValue(selected, out ikSettings))
            {
                ikSettings = new MyFeetIKSettings();
                ikSettings.Enabled = false;
                ikSettings.AboveReachableDistance = 0.1f;
                ikSettings.BelowReachableDistance = 0.1f;
                ikSettings.VerticalShiftDownGain = 0.1f;
                ikSettings.VerticalShiftUpGain = 0.1f;
                ikSettings.FootSize = new Vector3(0.1f, 0.1f, 0.2f);
            }

            updating = true;

            enabledIKState.IsChecked = ikSettings.Enabled;
            belowReachableDistance.Value = ikSettings.BelowReachableDistance;
            aboveReachableDistance.Value = ikSettings.AboveReachableDistance;
            verticalChangeUpGain.Value = ikSettings.VerticalShiftUpGain;
            verticalChangeDownGain.Value = ikSettings.VerticalShiftDownGain;
            ankleHeight.Value = ikSettings.FootSize.Y;
            footWidth.Value = ikSettings.FootSize.X;
            footLength.Value = ikSettings.FootSize.Z;

            updating = false;
        }
        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) builder.Inventory = new MyObjectBuilder_InventoryDefinition();
            InventoryVolume = builder.Inventory.InventoryVolume;
            InventoryMass = builder.Inventory.InventoryMass;
            InventorySizeX = builder.Inventory.InventorySizeX;
            InventorySizeY = builder.Inventory.InventorySizeY;
            InventorySizeZ = builder.Inventory.InventorySizeZ;
        }
예제 #3
0
        protected override void Init(MyObjectBuilder_DefinitionBase objectBuilder)
        {
            base.Init(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;
            LightOffset = builder.LightOffset;
            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;
            FeetIKEnabled = builder.FeetIKEnabled;
            ModelRootBoneName = builder.ModelRootBoneName;
            LeftHipBoneName = builder.LeftHipBoneName;
            LeftKneeBoneName = builder.LeftKneeBoneName;
            LeftAnkleBoneName = builder.LeftAnkleBoneName;
            RightHipBoneName = builder.RightHipBoneName;
            RightKneeBoneName = builder.RightKneeBoneName;
            RightAnkleBoneName = builder.RightAnkleBoneName;
            UsesAtmosphereDetector = builder.UsesAtmosphereDetector;
            NeedsOxygen = builder.NeedsOxygen;
            OxygenConsumptionMultiplier = builder.OxygenConsumptionMultiplier;
            OxygenConsumption = builder.OxygenConsumption;
            PressureLevelForLowDamage = builder.PressureLevelForLowDamage;
            DamageAmountAtZeroPressure = builder.DamageAmountAtZeroPressure;
            RagdollDataFile = builder.RagdollDataFile;
            //HelmetVariation = builder.HelmetVariation;
            JumpSoundName = builder.JumpSoundName;
            JetpackIdleSoundName = builder.JetpackIdleSoundName;
            JetpackRunSoundName = builder.JetpackRunSoundName;
            CrouchDownSoundName = builder.CrouchDownSoundName;
            CrouchUpSoundName = builder.CrouchUpSoundName;
            PainSoundName = builder.PainSoundName;
            SuffocateSoundName = builder.SuffocateSoundName;
            DeathSoundName = builder.DeathSoundName;
            DeathBySuffocationSoundName = builder.DeathBySuffocationSoundName;
            IronsightActSoundName = builder.IronsightActSoundName;
            IronsightDeactSoundName = builder.IronsightDeactSoundName;
            FastFlySoundName = builder.FastFlySoundName;
            HelmetOxygenNormalSoundName = builder.HelmetOxygenNormalSoundName;
            HelmetOxygenLowSoundName = builder.HelmetOxygenLowSoundName;
            HelmetOxygenCriticalSoundName = builder.HelmetOxygenCriticalSoundName;
            HelmetOxygenNoneSoundName = builder.HelmetOxygenNoneSoundName;
            LoopingFootsteps = builder.LoopingFootsteps;
            VisibleOnHud = builder.VisibleOnHud;
            UsableByPlayer = builder.UsableByPlayer;
            RagdollRootBody = builder.RagdollRootBody;
            InitialAnimation = builder.InitialAnimation;
            PhysicalMaterial = builder.PhysicalMaterial;
            JumpForce = builder.JumpForce;

            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);
                            }
                        }
                    }
                }
            }

	        SuitResourceStorage = builder.SuitResourceStorage;
            Jetpack = builder.Jetpack;

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

            if (builder.BoneLODs != null)
            {
                BoneLODs = builder.BoneLODs.ToDictionary(x => Convert.ToSingle(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 => new RagdollBoneSet(x.Bones, x.CollisionRadius));
            }

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

            Mass = builder.Mass;
            ImpulseLimit = builder.ImpulseLimit;

            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;
            CharacterCollisionWidth = builder.CharacterCollisionWidth;
            CharacterCollisionHeight = builder.CharacterCollisionHeight;
            CharacterCollisionCrouchHeight = builder.CharacterCollisionCrouchHeight;

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

            if (builder.EnabledComponents != null)
                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;
                }
                SpawnInventoryOnBodyRemoval = builder.SpawnInventoryOnBodyRemoval;
            }

            LootingTime = builder.LootingTime;
            DeadBodyShape = builder.DeadBodyShape;
            AnimationController = builder.AnimationController;
            MaxForce = builder.MaxForce;
        }