/// <summary> /// Load an entity /// </summary> /// <param name="evnt">our event</param> public static void LoadEntity(CreateNetworkedBuilding evnt) { GameObject prefab = PrefabDB.instance.GetGO(evnt.prefabID); if (prefab != null) { var instance = GameObject.Instantiate(prefab); UNetBuilding building = instance.GetComponent <UNetBuilding>(); building.LoadData(evnt); entities.Add(building); } }
public void LoadData(CreateNetworkedBuilding data) { this.transform.position = data.pos; this.transform.rotation = data.rot; CallLoad(this); this.networkedID = data.id; this.placedOn = UNetEntitiesManager.GetEntity(data.placedOnID); if (placedOn != null) { this.SnappedTo = placedOn.ReturnSocket(transform.position, this.buildingType); } this.PlaceBuilding(); UNetBuildingPlacer.LocalNetworkedBuildingPlaced(data.requester); this.health = data.health; }
public CreateNetworkedBuilding PackData(NetworkIdentity requester, bool initiateEvent) { if (initiateEvent) { CallPack(this); } var evnt = new CreateNetworkedBuilding(); evnt.pos = transform.position; evnt.rot = transform.rotation; evnt.id = networkedID; evnt.placedOnID = networkedPlacedOnID; evnt.prefabID = this.prefabID; evnt.health = this.health; evnt.requester = requester; return(evnt); }