本文整理汇总了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;
}
示例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);
}