public CubeBlockEntity(CubeGridEntity parent, MyObjectBuilder_CubeBlock definition, Object backingObject) : base(definition, backingObject) { m_parent = parent; EntityEventManager.EntityEvent newEvent = new EntityEventManager.EntityEvent(); newEvent.type = EntityEventManager.EntityEventType.OnCubeBlockCreated; newEvent.timestamp = DateTime.Now; newEvent.entity = this; if (m_parent.IsLoading) { newEvent.priority = 10; } else if (EntityId != 0) { newEvent.priority = 1; } else { newEvent.priority = 2; } EntityEventManager.Instance.AddEvent(newEvent); if (EntityId != 0) { GameEntityManager.AddEntity(EntityId, this); } m_buildPercent = definition.BuildPercent; m_integrityPercent = definition.IntegrityPercent; m_owner = definition.Owner; m_shareMode = definition.ShareMode; }
public BaseEntity(MyObjectBuilder_EntityBase baseEntity, Object backingObject) : base(baseEntity, backingObject) { if (baseEntity != null) { m_entityId = baseEntity.EntityId; if (baseEntity.PositionAndOrientation != null) { m_positionOrientation = baseEntity.PositionAndOrientation.GetValueOrDefault( ); } else { m_positionOrientation = new MyPositionAndOrientation( ); m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition(new Vector3(-500000, -500000, -500000), new Vector3(500000, 500000, 500000)); m_positionOrientation.Forward = new Vector3(0, 0, 1); m_positionOrientation.Up = new Vector3(0, 1, 0); } } else { m_entityId = 0; m_positionOrientation = new MyPositionAndOrientation( ); m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition(new Vector3(-500000, -500000, -500000), new Vector3(500000, 500000, 500000)); m_positionOrientation.Forward = new Vector3(0, 0, 1); m_positionOrientation.Up = new Vector3(0, 1, 0); } m_networkManager = new BaseEntityNetworkManager(this, GetEntityNetworkManager(BackingObject)); m_linearVelocity = new Vector3(0, 0, 0); m_angularVelocity = new Vector3(0, 0, 0); m_maxLinearVelocity = (float)104.7; if (EntityId != 0) { GameEntityManager.AddEntity(EntityId, this); } Action action = InternalRegisterEntityMovedEvent; SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action); }