本文整理汇总了C#中MyObjectBuilder_EntityBase类的典型用法代码示例。如果您正苦于以下问题:C# MyObjectBuilder_EntityBase类的具体用法?C# MyObjectBuilder_EntityBase怎么用?C# MyObjectBuilder_EntityBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyObjectBuilder_EntityBase类属于命名空间,在下文中一共展示了MyObjectBuilder_EntityBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init(MyObjectBuilder_EntityBase builder)
{
var ob = (MyObjectBuilder_VoxelMap)builder;
if (ob == null)
{
return;
}
m_storage = MyStorageBase.Load(ob.StorageName);
//By Gregory: Added for compatibility with old saves
if(m_storage == null)
{
return;
}
Init(builder, m_storage);
if (ob.ContentChanged.HasValue)
{
ContentChanged = ob.ContentChanged.Value;
}
else
{
ContentChanged = true;
}
}
示例2: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
this.objectBuilder = objectBuilder;
generator = Entity as IMyGravityGeneratorSphere;
generator.NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;
added = false;
}
示例3: Init
public override void Init(MyObjectBuilder_EntityBase builder)
{
ProfilerShort.Begin("base init");
SyncFlag = true;
base.Init(builder);
base.Init(null, null, null, null, null);
ProfilerShort.BeginNextBlock("Load file");
var ob = (MyObjectBuilder_VoxelMap)builder;
if (ob == null)
{
return;
}
if (ob.MutableStorage)
{
StorageName = ob.StorageName;
}
else
{
StorageName = string.Format("{0}-{1}", ob.StorageName, m_immutableStorageNameSalt++);
}
m_storage = MyStorageBase.Load(ob.StorageName);
m_storage.RangeChanged += storage_RangeChanged;
m_storageMax = m_storage.Size;
InitVoxelMap(ob.PositionAndOrientation.Value.Position, m_storage.Size);
ProfilerShort.End();
}
示例4: ConvertInventoryBagToEntityBase
private MyObjectBuilder_EntityBase ConvertInventoryBagToEntityBase(MyObjectBuilder_EntityBase oldBagBuilder, Vector3 linearVelocity, Vector3 angularVelocity)
{
MyObjectBuilder_EntityBase newBuilder = ConvertBuilderToEntityBase(oldBagBuilder, null);
if (newBuilder == null)
return null;
if (newBuilder.ComponentContainer == null)
newBuilder.ComponentContainer = MyObjectBuilderSerializer.CreateNewObject(typeof(MyObjectBuilder_ComponentContainer), newBuilder.SubtypeName) as MyObjectBuilder_ComponentContainer;
foreach (var componentBuidler in newBuilder.ComponentContainer.Components)
{
if (componentBuidler.Component is MyObjectBuilder_PhysicsComponentBase)
{
// Data already written.
return newBuilder;
}
}
MyObjectBuilder_PhysicsComponentBase physicsComponent = MyObjectBuilderSerializer.CreateNewObject(typeof(MyObjectBuilder_PhysicsBodyComponent),
newBuilder.SubtypeName) as MyObjectBuilder_PhysicsComponentBase;
newBuilder.ComponentContainer.Components.Add(new MyObjectBuilder_ComponentContainer.ComponentData()
{ Component = physicsComponent, TypeId = typeof(MyPhysicsComponentBase).Name });
physicsComponent.LinearVelocity = linearVelocity;
physicsComponent.AngularVelocity = angularVelocity;
return newBuilder;
}
示例5: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
ProfilerShort.Begin("MyEntity.Init(objectBuilder)");
if (objectBuilder != null)
{
if (objectBuilder.PositionAndOrientation.HasValue)
{
var posAndOrient = objectBuilder.PositionAndOrientation.Value;
MatrixD matrix = MatrixD.CreateWorld(posAndOrient.Position, posAndOrient.Forward, posAndOrient.Up);
MyUtils.AssertIsValid(matrix);
Container.Entity.PositionComp.SetWorldMatrix(matrix);
}
// Do not copy EntityID if it gets overwritten later. It might
// belong to some existing entity that we're making copy of.
if (objectBuilder.EntityId != 0)
Container.Entity.EntityId = objectBuilder.EntityId;
Container.Entity.Name = objectBuilder.Name;
Container.Entity.Render.PersistentFlags = objectBuilder.PersistentFlags;
}
AllocateEntityID();
Container.Entity.InScene = false;
MyEntities.SetEntityName(m_entity, false);
if (m_entity.SyncFlag)
{
m_entity.CreateSync();
}
GameLogic.Init(objectBuilder);
ProfilerShort.End();
}
示例6: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
base.Init(objectBuilder);
MyDefinitionManager.Static.TryGetDefinition(objectBuilder.GetId(), out m_definition);
Debug.Assert(m_definition != null, "Area marker definition cannot be null!");
if (m_definition == null) return;
m_tmpPlaceAreas.Clear();
MyPlaceAreas.Static.GetAllAreas(m_tmpPlaceAreas);
MyPlaceArea firstFound = null;
int markerCount = 0;
foreach (var area in m_tmpPlaceAreas)
{
if (area.AreaType == m_definition.Id.SubtypeId)
{
if (firstFound == null)
firstFound = area;
++markerCount;
}
}
if (m_definition.MaxNumber >= 0 && markerCount >= m_definition.MaxNumber)
{
if (SyncFlag)
firstFound.Entity.SyncObject.SendCloseRequest();
else
firstFound.Entity.Close();
}
m_tmpPlaceAreas.Clear();
InitInternal();
}
示例7: ConvertBuilderToEntityBase
/// <summary>
/// Converts the given builder to be of type EntityBase only with components. Prefix is added to sub type name for the created EntityBase and also for component builders.
/// Should be used when an entity was transformed to components and do not need specific entity implementation at all.
/// </summary>
protected MyObjectBuilder_EntityBase ConvertBuilderToEntityBase(MyObjectBuilder_EntityBase origEntity, string subTypeNamePrefix)
{
var origSubTypeName = !string.IsNullOrEmpty(origEntity.SubtypeName)
? origEntity.SubtypeName : (origEntity.EntityDefinitionId != null ? origEntity.EntityDefinitionId.Value.SubtypeName : null);
System.Diagnostics.Debug.Assert(origSubTypeName != null);
if (origSubTypeName == null)
return null;
var newSubTypeName = subTypeNamePrefix != null ? subTypeNamePrefix : "" + origSubTypeName;
MyObjectBuilder_EntityBase newBuilder = MyObjectBuilderSerializer.CreateNewObject(typeof(MyObjectBuilder_EntityBase), newSubTypeName) as MyObjectBuilder_EntityBase;
newBuilder.EntityId = origEntity.EntityId;
newBuilder.PersistentFlags = origEntity.PersistentFlags;
newBuilder.Name = origEntity.Name;
newBuilder.PositionAndOrientation = origEntity.PositionAndOrientation;
newBuilder.ComponentContainer = origEntity.ComponentContainer;
if (newBuilder.ComponentContainer != null && newBuilder.ComponentContainer.Components.Count > 0)
{
foreach (var componentBuidler in newBuilder.ComponentContainer.Components)
{
if (!string.IsNullOrEmpty(componentBuidler.Component.SubtypeName) && componentBuidler.Component.SubtypeName == origSubTypeName)
componentBuidler.Component.SubtypeName = newSubTypeName;
}
}
return newBuilder;
}
示例8: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
if (objectBuilder.SubtypeName != null && objectBuilder.SubtypeName.Length > 0)
m_physicalItemId = new MyDefinitionId(typeof(MyObjectBuilder_PhysicalGunObject), objectBuilder.SubtypeName + "Item");
PhysicalObject = (MyObjectBuilder_PhysicalGunObject)MyObjectBuilderSerializer.CreateNewObject(m_physicalItemId);
base.Init(objectBuilder, m_physicalItemId);
var definition = MyDefinitionManager.Static.GetPhysicalItemDefinition(m_physicalItemId);
Init(null, definition.Model, null, null, null);
Render.CastShadows = true;
Render.NeedsResolveCastShadow = false;
PhysicalObject.GunEntity = (MyObjectBuilder_EntityBase)objectBuilder.Clone();
PhysicalObject.GunEntity.EntityId = this.EntityId;
foreach (ToolSound toolSound in m_handItemDef.ToolSounds)
{
if (toolSound.type == null || toolSound.subtype == null || toolSound.sound == null)
continue;
if (toolSound.type.Equals("Main"))
{
if(toolSound.subtype.Equals("Idle"))
weldSoundIdle = new MySoundPair(toolSound.sound);
if (toolSound.subtype.Equals("Weld"))
weldSoundWeld = new MySoundPair(toolSound.sound);
}
}
}
示例9: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
// Fix old EntityDefinitionId with MyObjectBuilder_EntityBase.
if (objectBuilder.EntityDefinitionId != null && objectBuilder.EntityDefinitionId.Value.TypeId != typeof(MyObjectBuilder_InventoryBagEntity))
{
objectBuilder.EntityDefinitionId = new SerializableDefinitionId(typeof(MyObjectBuilder_InventoryBagEntity), objectBuilder.EntityDefinitionId.Value.SubtypeName);
}
base.Init(objectBuilder);
if (objectBuilder is MyObjectBuilder_InventoryBagEntity)
{
var builderIBE = (MyObjectBuilder_InventoryBagEntity)objectBuilder;
var physicsComponentBuilder = GetPhysicsComponentBuilder(builderIBE);
if (physicsComponentBuilder == null)
{
Physics.LinearVelocity = builderIBE.LinearVelocity;
Physics.AngularVelocity = builderIBE.AngularVelocity;
}
}
else if (objectBuilder is MyObjectBuilder_ReplicableEntity)
{
// Backward compatibility
var builderRE = (MyObjectBuilder_ReplicableEntity)objectBuilder;
Physics.LinearVelocity = builderRE.LinearVelocity;
Physics.AngularVelocity = builderRE.AngularVelocity;
}
else
{
Debug.Fail("Unknown object builder for inventory bag");
}
}
示例10: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
_objectBuilder = objectBuilder;
if (!_initialized)
_Init();
base.Init(objectBuilder);
}
示例11: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
_objectBuilder = objectBuilder;
if ( MyAPIGateway.Multiplayer != null && MyAPIGateway.Multiplayer.MultiplayerActive)
_Init();
base.Init(objectBuilder);
}
示例12: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
base.Init(objectBuilder);
Init(null, "Models\\Weapons\\AngleGrinder.mwm", null, null, null);
Render.CastShadows = true;
Render.NeedsResolveCastShadow = false;
PhysicalObject.GunEntity = (MyObjectBuilder_EntityBase)objectBuilder.Clone();
PhysicalObject.GunEntity.EntityId = this.EntityId;
}
示例13: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
base.Init(objectBuilder);
m_MergeBlock = Container.Entity as InGame.IMyShipMergeBlock;
//m_Grid = m_MergeBlock.CubeGrid as IMyCubeGrid;
m_Logger = new Logger(m_MergeBlock.EntityId.ToString(), "MergeBlock");
log("Attached to merge block", "Init");
(m_MergeBlock as IMyShipMergeBlock).BeforeMerge += beforeMerge;
}
示例14: Init
// Gamelogic initialization
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
// Update each frame, note this may not work for all object's types!
Entity.NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;
block = Entity as BlockModAPIType;
if (block == null || MyAPIGateway.Session == null) return;
BlockInit();
active = true;
}
示例15: Init
public override void Init(MyObjectBuilder_EntityBase objectBuilder)
{
//Get door that script it attatched to.
Door = Entity as IMyDoor;
//Set up detonation callback when 'door' is opened.
Door.DoorStateChanged += Detonate;
m_objectBuilder = objectBuilder;
//DEBUG
//MyLogger.Default.ToScreen = false ;
//MyLogger.Default.WriteLine("Successfully placed a bolt");
}