//---------------------------------------------------------- // CONSTRUCTORS //---------------------------------------------------------- public EntityDataManager( string gameType, string marking, LVCGame.UnitForceType force ) { this.lvcUnityAmbassador = LVCUnityAmbassador.GetInstance(); this.lvcClient = lvcUnityAmbassador.GetLVCClient(); // initialise the entity data container which will hold salient details about // the entity state which we want to send in LVC updates entityData = new LVCGame.EntityData(); entityData.id = new LVCGame.EntityID(); entityData.physics = new LVCGame.EntityPhysics(); entityData.properties = new LVCGame.EntityProperties(); entityData.properties.force = force; // assign a unique ID number to this entity entityData.id.instance = lvcUnityAmbassador.GetNextEntityID(); // initialise types and markings entityData.id.gameType = gameType; entityData.id.marking = marking; lvcGameState = LVCGameState.UNINTIALISED; }
/** * Causes the entity to be removed from the LVC Game world. After this is called, * no further updates will be sent. */ public void Delete() { lock( this ) { if( lvcGameState == LVCGameState.CREATED ) { this.lvcUnityAmbassador.Deregister( ref this.entityData ); lvcGameState = LVCGameState.DELETED; } } }
//---------------------------------------------------------- // INSTANCE METHODS //---------------------------------------------------------- /** * Creates the entity in the LVC Game world - until this is called, LVC Game * does not consider the entity to "exist" */ public void Create( GameObject gameObject ) { lock( this ) { if( lvcGameState == LVCGameState.UNINTIALISED ) { this.lvcUnityAmbassador.Register( ref this.entityData, gameObject ); lvcGameState = LVCGameState.CREATED; } } }