Example #1
0
        protected override void Init(MyObjectBuilder_DefinitionBase objectBuilder)
        {
            base.Init(objectBuilder);
            MyObjectBuilder_CharacterDefinition definition = (MyObjectBuilder_CharacterDefinition)objectBuilder;

            this.Name                          = definition.Name;
            this.Model                         = definition.Model;
            this.ReflectorTexture              = definition.ReflectorTexture;
            this.LeftGlare                     = definition.LeftGlare;
            this.RightGlare                    = definition.RightGlare;
            this.LeftLightBone                 = definition.LeftLightBone;
            this.RightLightBone                = definition.RightLightBone;
            this.LightOffset                   = definition.LightOffset;
            this.LightGlareSize                = definition.LightGlareSize;
            this.HeadBone                      = definition.HeadBone;
            this.Camera3rdBone                 = definition.Camera3rdBone;
            this.LeftHandIKStartBone           = definition.LeftHandIKStartBone;
            this.LeftHandIKEndBone             = definition.LeftHandIKEndBone;
            this.RightHandIKStartBone          = definition.RightHandIKStartBone;
            this.RightHandIKEndBone            = definition.RightHandIKEndBone;
            this.WeaponBone                    = definition.WeaponBone;
            this.LeftHandItemBone              = definition.LeftHandItemBone;
            this.RighHandItemBone              = definition.RightHandItemBone;
            this.Skeleton                      = definition.Skeleton;
            this.LeftForearmBone               = definition.LeftForearmBone;
            this.LeftUpperarmBone              = definition.LeftUpperarmBone;
            this.RightForearmBone              = definition.RightForearmBone;
            this.RightUpperarmBone             = definition.RightUpperarmBone;
            this.SpineBone                     = definition.SpineBone;
            this.BendMultiplier1st             = definition.BendMultiplier1st;
            this.BendMultiplier3rd             = definition.BendMultiplier3rd;
            this.MaterialsDisabledIn1st        = definition.MaterialsDisabledIn1st;
            this.FeetIKEnabled                 = definition.FeetIKEnabled;
            this.ModelRootBoneName             = definition.ModelRootBoneName;
            this.LeftHipBoneName               = definition.LeftHipBoneName;
            this.LeftKneeBoneName              = definition.LeftKneeBoneName;
            this.LeftAnkleBoneName             = definition.LeftAnkleBoneName;
            this.RightHipBoneName              = definition.RightHipBoneName;
            this.RightKneeBoneName             = definition.RightKneeBoneName;
            this.RightAnkleBoneName            = definition.RightAnkleBoneName;
            this.UsesAtmosphereDetector        = definition.UsesAtmosphereDetector;
            this.UsesReverbDetector            = definition.UsesReverbDetector;
            this.NeedsOxygen                   = definition.NeedsOxygen;
            this.OxygenConsumptionMultiplier   = definition.OxygenConsumptionMultiplier;
            this.OxygenConsumption             = definition.OxygenConsumption;
            this.OxygenSuitRefillTime          = definition.OxygenSuitRefillTime;
            this.MinOxygenLevelForSuitRefill   = definition.MinOxygenLevelForSuitRefill;
            this.PressureLevelForLowDamage     = definition.PressureLevelForLowDamage;
            this.DamageAmountAtZeroPressure    = definition.DamageAmountAtZeroPressure;
            this.RagdollDataFile               = definition.RagdollDataFile;
            this.JumpSoundName                 = definition.JumpSoundName;
            this.JetpackIdleSoundName          = definition.JetpackIdleSoundName;
            this.JetpackRunSoundName           = definition.JetpackRunSoundName;
            this.CrouchDownSoundName           = definition.CrouchDownSoundName;
            this.CrouchUpSoundName             = definition.CrouchUpSoundName;
            this.PainSoundName                 = definition.PainSoundName;
            this.SuffocateSoundName            = definition.SuffocateSoundName;
            this.DeathSoundName                = definition.DeathSoundName;
            this.DeathBySuffocationSoundName   = definition.DeathBySuffocationSoundName;
            this.IronsightActSoundName         = definition.IronsightActSoundName;
            this.IronsightDeactSoundName       = definition.IronsightDeactSoundName;
            this.FastFlySoundName              = definition.FastFlySoundName;
            this.HelmetOxygenNormalSoundName   = definition.HelmetOxygenNormalSoundName;
            this.HelmetOxygenLowSoundName      = definition.HelmetOxygenLowSoundName;
            this.HelmetOxygenCriticalSoundName = definition.HelmetOxygenCriticalSoundName;
            this.HelmetOxygenNoneSoundName     = definition.HelmetOxygenNoneSoundName;
            this.MovementSoundName             = definition.MovementSoundName;
            this.MagnetBootsStartSoundName     = definition.MagnetBootsStartSoundName;
            this.MagnetBootsStepsSoundName     = definition.MagnetBootsStepsSoundName;
            this.MagnetBootsEndSoundName       = definition.MagnetBootsEndSoundName;
            this.MagnetBootsProximitySoundName = definition.MagnetBootsProximitySoundName;
            this.LoopingFootsteps              = definition.LoopingFootsteps;
            this.VisibleOnHud                  = definition.VisibleOnHud;
            this.UsableByPlayer                = definition.UsableByPlayer;
            this.RagdollRootBody               = definition.RagdollRootBody;
            this.InitialAnimation              = definition.InitialAnimation;
            this.PhysicalMaterial              = definition.PhysicalMaterial;
            this.JumpForce                     = definition.JumpForce;
            this.RotationToSupport             = definition.RotationToSupport;
            this.HUD = definition.HUD;
            this.EnableFirstPersonView        = definition.EnableFirstPersonView;
            this.BreathCalmSoundName          = definition.BreathCalmSoundName;
            this.BreathHeavySoundName         = definition.BreathHeavySoundName;
            this.OxygenChokeNormalSoundName   = definition.OxygenChokeNormalSoundName;
            this.OxygenChokeLowSoundName      = definition.OxygenChokeLowSoundName;
            this.OxygenChokeCriticalSoundName = definition.OxygenChokeCriticalSoundName;
            this.FeetIKSettings = new Dictionary <MyCharacterMovementEnum, MyFeetIKSettings>();
            if (definition.IKSettings != null)
            {
                MyObjectBuilder_MyFeetIKSettings[] iKSettings = definition.IKSettings;
                int index = 0;
                while (index < iKSettings.Length)
                {
                    MyObjectBuilder_MyFeetIKSettings settings = iKSettings[index];
                    char[]   separator = new char[] { ',' };
                    string[] strArray  = settings.MovementState.Split(separator);
                    int      num2      = 0;
                    while (true)
                    {
                        MyCharacterMovementEnum enum2;
                        if (num2 >= strArray.Length)
                        {
                            index++;
                            break;
                        }
                        string str = strArray[num2].Trim();
                        if ((str != "") && Enum.TryParse <MyCharacterMovementEnum>(str, true, out enum2))
                        {
                            MyFeetIKSettings settings2 = new MyFeetIKSettings {
                                Enabled = settings.Enabled,
                                AboveReachableDistance = settings.AboveReachableDistance,
                                BelowReachableDistance = settings.BelowReachableDistance,
                                VerticalShiftDownGain  = settings.VerticalShiftDownGain,
                                VerticalShiftUpGain    = settings.VerticalShiftUpGain,
                                FootSize = new Vector3(settings.FootWidth, settings.AnkleHeight, settings.FootLenght)
                            };
                            this.FeetIKSettings.Add(enum2, settings2);
                        }
                        num2++;
                    }
                }
            }
            this.SuitResourceStorage = definition.SuitResourceStorage;
            this.Jetpack             = definition.Jetpack;
            if (definition.BoneSets != null)
            {
                this.BoneSets = definition.BoneSets.ToDictionary <MyBoneSetDefinition, string, string[]>(x => x.Name, x => x.Bones.Split(new char[] { ' ' }));
            }
            if (definition.BoneLODs != null)
            {
                this.BoneLODs = definition.BoneLODs.ToDictionary <MyBoneSetDefinition, float, string[]>(x => Convert.ToSingle(x.Name), x => x.Bones.Split(new char[] { ' ' }));
            }
            if (definition.AnimationMappings != null)
            {
                this.AnimationNameToSubtypeName = definition.AnimationMappings.ToDictionary <MyMovementAnimationMapping, string, string>(mapping => mapping.Name, mapping => mapping.AnimationSubtypeName);
            }
            if (definition.RagdollBonesMappings != null)
            {
                this.RagdollBonesMappings = definition.RagdollBonesMappings.ToDictionary <MyRagdollBoneSetDefinition, string, RagdollBoneSet>(x => x.Name, x => new RagdollBoneSet(x.Bones, x.CollisionRadius));
            }
            if (definition.RagdollPartialSimulations != null)
            {
                this.RagdollPartialSimulations = definition.RagdollPartialSimulations.ToDictionary <MyBoneSetDefinition, string, string[]>(x => x.Name, x => x.Bones.Split(new char[] { ' ' }));
            }
            this.Mass         = definition.Mass;
            this.ImpulseLimit = definition.ImpulseLimit;
            this.VerticalPositionFlyingOnly = definition.VerticalPositionFlyingOnly;
            this.UseOnlyWalking             = definition.UseOnlyWalking;
            this.MaxSlope                       = definition.MaxSlope;
            this.MaxSprintSpeed                 = definition.MaxSprintSpeed;
            this.MaxRunSpeed                    = definition.MaxRunSpeed;
            this.MaxBackrunSpeed                = definition.MaxBackrunSpeed;
            this.MaxRunStrafingSpeed            = definition.MaxRunStrafingSpeed;
            this.MaxWalkSpeed                   = definition.MaxWalkSpeed;
            this.MaxBackwalkSpeed               = definition.MaxBackwalkSpeed;
            this.MaxWalkStrafingSpeed           = definition.MaxWalkStrafingSpeed;
            this.MaxCrouchWalkSpeed             = definition.MaxCrouchWalkSpeed;
            this.MaxCrouchBackwalkSpeed         = definition.MaxCrouchBackwalkSpeed;
            this.MaxCrouchStrafingSpeed         = definition.MaxCrouchStrafingSpeed;
            this.CharacterHeadSize              = definition.CharacterHeadSize;
            this.CharacterHeadHeight            = definition.CharacterHeadHeight;
            this.CharacterCollisionScale        = definition.CharacterCollisionScale;
            this.CharacterCollisionWidth        = definition.CharacterCollisionWidth;
            this.CharacterCollisionHeight       = definition.CharacterCollisionHeight;
            this.CharacterCollisionCrouchHeight = definition.CharacterCollisionCrouchHeight;
            this.CanCrouch                      = definition.CanCrouch;
            this.CanIronsight                   = definition.CanIronsight;
            this.InventoryDefinition            = (definition.Inventory != null) ? definition.Inventory : new MyObjectBuilder_InventoryDefinition();
            if (definition.EnabledComponents != null)
            {
                char[] separator = new char[] { ' ' };
                this.EnabledComponents = definition.EnabledComponents.Split(separator).ToList <string>();
            }
            this.EnableSpawnInventoryAsContainer = definition.EnableSpawnInventoryAsContainer;
            if (this.EnableSpawnInventoryAsContainer)
            {
                if (definition.InventorySpawnContainerId != null)
                {
                    this.InventorySpawnContainerId = new MyDefinitionId?(definition.InventorySpawnContainerId.Value);
                }
                this.SpawnInventoryOnBodyRemoval = definition.SpawnInventoryOnBodyRemoval;
            }
            this.LootingTime         = definition.LootingTime;
            this.DeadBodyShape       = definition.DeadBodyShape;
            this.AnimationController = definition.AnimationController;
            this.MaxForce            = definition.MaxForce;
            this.SuitConsumptionInTemperatureExtreme = definition.SuitConsumptionInTemperatureExtreme;
        }
Example #2
0
        public override MyObjectBuilder_DefinitionBase GetObjectBuilder()
        {
            MyObjectBuilder_CharacterDefinition objectBuilder = (MyObjectBuilder_CharacterDefinition)base.GetObjectBuilder();

            objectBuilder.Name                            = this.Name;
            objectBuilder.Model                           = this.Model;
            objectBuilder.ReflectorTexture                = this.ReflectorTexture;
            objectBuilder.LeftGlare                       = this.LeftGlare;
            objectBuilder.RightGlare                      = this.RightGlare;
            objectBuilder.LightGlareSize                  = this.LightGlareSize;
            objectBuilder.Skeleton                        = this.Skeleton;
            objectBuilder.LeftForearmBone                 = this.LeftForearmBone;
            objectBuilder.LeftUpperarmBone                = this.LeftUpperarmBone;
            objectBuilder.RightForearmBone                = this.RightForearmBone;
            objectBuilder.RightUpperarmBone               = this.RightUpperarmBone;
            objectBuilder.SpineBone                       = this.SpineBone;
            objectBuilder.MaterialsDisabledIn1st          = this.MaterialsDisabledIn1st;
            objectBuilder.UsesAtmosphereDetector          = this.UsesAtmosphereDetector;
            objectBuilder.UsesReverbDetector              = this.UsesReverbDetector;
            objectBuilder.NeedsOxygen                     = this.NeedsOxygen;
            objectBuilder.OxygenConsumptionMultiplier     = this.OxygenConsumptionMultiplier;
            objectBuilder.OxygenConsumption               = this.OxygenConsumption;
            objectBuilder.OxygenSuitRefillTime            = this.OxygenSuitRefillTime;
            objectBuilder.MinOxygenLevelForSuitRefill     = this.MinOxygenLevelForSuitRefill;
            objectBuilder.PressureLevelForLowDamage       = this.PressureLevelForLowDamage;
            objectBuilder.DamageAmountAtZeroPressure      = this.DamageAmountAtZeroPressure;
            objectBuilder.JumpSoundName                   = this.JumpSoundName;
            objectBuilder.JetpackIdleSoundName            = this.JetpackIdleSoundName;
            objectBuilder.JetpackRunSoundName             = this.JetpackRunSoundName;
            objectBuilder.CrouchDownSoundName             = this.CrouchDownSoundName;
            objectBuilder.CrouchUpSoundName               = this.CrouchUpSoundName;
            objectBuilder.SuffocateSoundName              = this.SuffocateSoundName;
            objectBuilder.PainSoundName                   = this.PainSoundName;
            objectBuilder.DeathSoundName                  = this.DeathSoundName;
            objectBuilder.DeathBySuffocationSoundName     = this.DeathBySuffocationSoundName;
            objectBuilder.IronsightActSoundName           = this.IronsightActSoundName;
            objectBuilder.IronsightDeactSoundName         = this.IronsightDeactSoundName;
            objectBuilder.LoopingFootsteps                = this.LoopingFootsteps;
            objectBuilder.MagnetBootsStartSoundName       = this.MagnetBootsStartSoundName;
            objectBuilder.MagnetBootsEndSoundName         = this.MagnetBootsEndSoundName;
            objectBuilder.MagnetBootsStepsSoundName       = this.MagnetBootsStepsSoundName;
            objectBuilder.MagnetBootsProximitySoundName   = this.MagnetBootsProximitySoundName;
            objectBuilder.VisibleOnHud                    = this.VisibleOnHud;
            objectBuilder.UsableByPlayer                  = this.UsableByPlayer;
            objectBuilder.SuitResourceStorage             = this.SuitResourceStorage;
            objectBuilder.Jetpack                         = this.Jetpack;
            objectBuilder.VerticalPositionFlyingOnly      = this.VerticalPositionFlyingOnly;
            objectBuilder.UseOnlyWalking                  = this.UseOnlyWalking;
            objectBuilder.MaxSlope                        = this.MaxSlope;
            objectBuilder.MaxSprintSpeed                  = this.MaxSprintSpeed;
            objectBuilder.MaxRunSpeed                     = this.MaxRunSpeed;
            objectBuilder.MaxBackrunSpeed                 = this.MaxBackrunSpeed;
            objectBuilder.MaxRunStrafingSpeed             = this.MaxRunStrafingSpeed;
            objectBuilder.MaxWalkSpeed                    = this.MaxWalkSpeed;
            objectBuilder.MaxBackwalkSpeed                = this.MaxBackwalkSpeed;
            objectBuilder.MaxWalkStrafingSpeed            = this.MaxWalkStrafingSpeed;
            objectBuilder.MaxCrouchWalkSpeed              = this.MaxCrouchWalkSpeed;
            objectBuilder.MaxCrouchBackwalkSpeed          = this.MaxCrouchBackwalkSpeed;
            objectBuilder.MaxCrouchStrafingSpeed          = this.MaxCrouchStrafingSpeed;
            objectBuilder.CharacterHeadSize               = this.CharacterHeadSize;
            objectBuilder.CharacterHeadHeight             = this.CharacterHeadHeight;
            objectBuilder.CharacterCollisionScale         = this.CharacterCollisionScale;
            objectBuilder.CharacterCollisionWidth         = this.CharacterCollisionWidth;
            objectBuilder.CharacterCollisionHeight        = this.CharacterCollisionHeight;
            objectBuilder.CharacterCollisionCrouchHeight  = this.CharacterCollisionCrouchHeight;
            objectBuilder.CanCrouch                       = this.CanCrouch;
            objectBuilder.CanIronsight                    = this.CanIronsight;
            objectBuilder.Inventory                       = this.InventoryDefinition;
            objectBuilder.PhysicalMaterial                = this.PhysicalMaterial;
            objectBuilder.EnabledComponents               = string.Join(" ", this.EnabledComponents);
            objectBuilder.EnableSpawnInventoryAsContainer = this.EnableSpawnInventoryAsContainer;
            if (this.EnableSpawnInventoryAsContainer)
            {
                if (this.InventorySpawnContainerId != null)
                {
                    objectBuilder.InventorySpawnContainerId = new SerializableDefinitionId?(this.InventorySpawnContainerId.Value);
                }
                objectBuilder.SpawnInventoryOnBodyRemoval = this.SpawnInventoryOnBodyRemoval;
            }
            objectBuilder.LootingTime                         = this.LootingTime;
            objectBuilder.DeadBodyShape                       = this.DeadBodyShape;
            objectBuilder.AnimationController                 = this.AnimationController;
            objectBuilder.MaxForce                            = this.MaxForce;
            objectBuilder.RotationToSupport                   = this.RotationToSupport;
            objectBuilder.BreathCalmSoundName                 = this.BreathCalmSoundName;
            objectBuilder.BreathHeavySoundName                = this.BreathHeavySoundName;
            objectBuilder.OxygenChokeNormalSoundName          = this.OxygenChokeNormalSoundName;
            objectBuilder.OxygenChokeLowSoundName             = this.OxygenChokeLowSoundName;
            objectBuilder.OxygenChokeCriticalSoundName        = this.OxygenChokeCriticalSoundName;
            objectBuilder.SuitConsumptionInTemperatureExtreme = this.SuitConsumptionInTemperatureExtreme;
            return(objectBuilder);
        }