//maybe this should be done in the SystemState? void On_entityChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db) { _changesNextFrame.Add(new EntityChangeData() { ChangeType = changeType, Datablob = db, Entity = Entity }); switch (changeType) { case EntityChangeData.EntityChangeType.DBAdded: DataBlobs[db.GetType()] = db; break; case EntityChangeData.EntityChangeType.DBRemoved: DataBlobs.Remove(db.GetType()); break; case EntityChangeData.EntityChangeType.EntityRemoved: DataBlobs.Clear(); IsDestroyed = true; break; default: break; } }
void ActualEntity_ChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db) { if (changeType == EntityChangeData.EntityChangeType.EntityRemoved) { Position.GetDataFrom = DataFrom.Memory; } }
void Entity_ChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db) { if (changeType == EntityChangeData.EntityChangeType.DBAdded) { if (db is OrbitDB) { _orbitDB = (OrbitDB)db; var i = _orbitDB.Inclination; var aop = _orbitDB.ArgumentOfPeriapsis; var loan = _orbitDB.LongitudeOfAscendingNode; _lop = (float)OrbitMath.GetLongditudeOfPeriapsis(i, aop, loan); } else if (db is WarpMovingDB) { _warpMoveDB = (WarpMovingDB)db; } } else if (changeType == EntityChangeData.EntityChangeType.DBRemoved) { if (db is OrbitDB) { _orbitDB = null; } else if (db is WarpMovingDB) { _warpMoveDB = null; } } }
void Entity_ChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db) { if (changeType == EntityChangeData.EntityChangeType.DBAdded) { if (db is OrbitDB) { _orbitDB = (OrbitDB)db; var i = Angle.ToRadians(_orbitDB.Inclination); var aop = Angle.ToRadians(_orbitDB.ArgumentOfPeriapsis); var loan = Angle.ToRadians(_orbitDB.LongitudeOfAscendingNode); _lop = (float)OrbitMath.GetLongditudeOfPeriapsis(i, aop, loan); } else if (db is TranslateMoveDB) { _tlmoveDB = (TranslateMoveDB)db; } } else if (changeType == EntityChangeData.EntityChangeType.DBRemoved) { if (db is OrbitDB) { _orbitDB = null; } else if (db is TranslateMoveDB) { _tlmoveDB = null; } } }
public void InvokeChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db) { ChangeEvent?.Invoke(changeType, db); }
void HandleEntityChangeData(NetIncomingMessage message) { EntityChangeData.EntityChangeType changeType = (EntityChangeData.EntityChangeType)message.ReadByte(); switch (changeType) { case EntityChangeData.EntityChangeType.EntityAdded: { HandleEntityData(message); } break; case EntityChangeData.EntityChangeType.EntityRemoved: { Guid entityID = new Guid(message.ReadBytes(16)); Entity entity; if (!this.Game.GlobalManager.FindEntityByGuid(entityID, out entity)) { Messages.Add("Remove Entity Fail: No Entity for ID: " + entityID); } else { entity.Manager.RemoveEntity(entity); } } break; case EntityChangeData.EntityChangeType.DBAdded: { HandleDatablob(message); } break; case EntityChangeData.EntityChangeType.DBRemoved: { Guid entityID = new Guid(message.ReadBytes(16)); //entity guid. string name = message.ReadString(); //datablob name int typeIndex = message.ReadInt32(); //datablob typeIndex Entity entity; if (!this.Game.GlobalManager.FindEntityByGuid(entityID, out entity)) { Messages.Add("Remove " + name + " Datablob Fail: No Entity for ID: " + entityID + " this is not critical and can be ignored."); } else { if (entity.HasDataBlob(typeIndex)) { entity.RemoveDataBlob(typeIndex); Messages.Add("Successfully removed " + name + " Datablob from entity " + entityID); } else { Messages.Add("Remove " + name + " Datablob Fail: datablob not found in entity, this is not critical and can be ignored."); } } } break; default: throw new Exception("Network classes need to handle EntityChangeType, this is probibly caused by a game version missmatch"); } }
void Entity_ChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db) { }