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(); }