当前位置: 首页>>代码示例>>C#>>正文


C# MyCharacter.Init方法代码示例

本文整理汇总了C#中Sandbox.Game.Entities.Character.MyCharacter.Init方法的典型用法代码示例。如果您正苦于以下问题:C# MyCharacter.Init方法的具体用法?C# MyCharacter.Init怎么用?C# MyCharacter.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sandbox.Game.Entities.Character.MyCharacter的用法示例。


在下文中一共展示了MyCharacter.Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateCharacterBase

        private static MyCharacter CreateCharacterBase(MatrixD worldMatrix, ref Vector3 velocity, string characterName, string model, Vector3? colorMask, bool AIMode, bool useInventory = true, MyBotDefinition botDefinition = null)
        {
            MyCharacter character = new MyCharacter();
            MyObjectBuilder_Character objectBuilder = MyCharacter.Random();
            objectBuilder.CharacterModel = model ?? objectBuilder.CharacterModel;

            if (colorMask.HasValue)
                objectBuilder.ColorMaskHSV = colorMask.Value;

            objectBuilder.JetpackEnabled = MySession.Static.CreativeMode;
            objectBuilder.Battery = new MyObjectBuilder_Battery { CurrentCapacity = 1 };
            objectBuilder.AIMode = AIMode;
            objectBuilder.DisplayName = characterName;
            objectBuilder.LinearVelocity = velocity;
            objectBuilder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);
            character.Init(objectBuilder);

            MyEntities.RaiseEntityCreated(character);
            MyEntities.Add(character);

            System.Diagnostics.Debug.Assert(character.GetInventory() as MyInventory != null, "Null or unexpected inventory type returned!");
            if (useInventory)
                MyWorldGenerator.InitInventoryWithDefaults(character.GetInventory() as MyInventory);
            else if (botDefinition != null)
            {
                // use inventory from bot definition
                botDefinition.AddItems(character);
            }
            //character.PositionComp.SetWorldMatrix(worldMatrix);
            if (velocity.Length() > 0)
            {
                var jetpack = character.JetpackComp;

                if (jetpack != null)
                    jetpack.EnableDampeners(false, false);
            }

            return character;
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:39,代码来源:MyCharacter.cs

示例2: SetupCharacter

            public override void SetupCharacter(MyWorldGenerator.Args generatorArgs)
            {
                Debug.Assert(MySession.Static.LocalHumanPlayer != null, "Local controller does not exist!");
                if (MySession.Static.LocalHumanPlayer == null) return;

                var characterOb = Sandbox.Game.Entities.Character.MyCharacter.Random();

                if (Transform.HasValue && MyPerGameSettings.CharacterStartsOnVoxel)
                {
                    var transform = Transform.Value;
                    transform.Position = FixPositionToVoxel(transform.Position);
                    characterOb.PositionAndOrientation = transform;
                }
                else
                {
                    characterOb.PositionAndOrientation = Transform;
                }
                characterOb.JetpackEnabled = JetpackEnabled;
                characterOb.DampenersEnabled = DampenersEnabled;

                if (characterOb.Inventory == null)
                    characterOb.Inventory = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_Inventory>();
                FillInventoryWithDefaults(characterOb.Inventory, generatorArgs.Scenario);

                var character = new MyCharacter();
                character.Name = "Player";
                character.Init(characterOb);
                MyEntities.RaiseEntityCreated(character);
                
                MyEntities.Add(character);

                this.CreateAndSetPlayerFaction();

                MySession.Static.LocalHumanPlayer.SpawnIntoCharacter(character);
            }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:35,代码来源:MyWorldGenerator.StartingStates.cs


注:本文中的Sandbox.Game.Entities.Character.MyCharacter.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。