예제 #1
0
        public override void OnEvent(CreateNetworkedBuilding evnt)
        {
            GameObject prefab = PrefabDB.instance.GetGO(evnt.prefabID);

            if (prefab != null && evnt.requester != null)
            {
                var instance = GameObject.Instantiate(prefab);

                BoltBuilding building = instance.GetComponent <BoltBuilding>();

                building.transform.position = evnt.pos;
                building.transform.rotation = evnt.rot;

                if (!building.CheckConditions()) // check conditions serverside
                {
                    Destroy(instance);
                    return;
                }

                entities.Add(building);

                evnt.health = building.maxHealth;
                evnt.id     = entities.Count;

                building.LoadData(evnt);

                building.PackData(evnt.requester, false).Send();
            }
        }
예제 #2
0
        public override void OnEvent(CreateNetworkedBuilding evnt)
        {
            if (BoltNetwork.isServer)
            {
                return;
            }

            BoltEntitiesManager.LoadEntity(evnt);
        }
예제 #3
0
        public static void LoadEntity(CreateNetworkedBuilding evnt)
        {
            GameObject prefab = PrefabDB.instance.GetGO(evnt.prefabID);

            if (prefab != null)
            {
                var instance = GameObject.Instantiate(prefab);

                BoltBuilding building = instance.GetComponent <BoltBuilding>();

                building.LoadData(evnt);
                entities.Add(building);
            }
        }
예제 #4
0
        public override void PlaceBuilding()
        {
            BaseBuilding.CallPack(currentBuilding);

            var evnt = CreateNetworkedBuilding.Create(Bolt.GlobalTargets.OnlyServer, Bolt.ReliabilityModes.Unreliable);
            evnt.pos = currentBuilding.transform.position;
            evnt.rot = currentBuilding.transform.rotation;

            evnt.placedOnID = ((BoltBuilding)(currentBuilding)).networkedPlacedOnID;
            evnt.prefabID = currentBuilding.prefabID;

            evnt.requester = entity;

            evnt.Send();

            DestroyCurrentBuilding();
            ResetBuildingInstance();
        }
예제 #5
0
        public override void SceneLoadRemoteDone(BoltConnection connection)
        {
            BoltBuilding building;

            for (int i = 0; i < entities.Count; i++)
            {
                building = entities[i];

                BaseBuilding.CallPack(building);

                var evnt = CreateNetworkedBuilding.Create(connection, Bolt.ReliabilityModes.ReliableOrdered);
                evnt.pos    = building.transform.position;
                evnt.rot    = building.transform.rotation;
                evnt.health = building.health;

                evnt.id         = building.networkedID;
                evnt.placedOnID = building.networkedPlacedOnID;
                evnt.prefabID   = building.prefabID;
                evnt.Send();
            }
        }
예제 #6
0
        public void LoadData(CreateNetworkedBuilding data)
        {
            this.transform.position = data.pos;
            this.transform.rotation = data.rot;

            CallLoad(this);

            this.networkedID = data.id;
            this.placedOn    = BoltEntitiesManager.GetEntity(data.placedOnID);

            if (placedOn != null)
            {
                this.SnappedTo = placedOn.ReturnSocket(transform.position, this.buildingType);
            }

            this.PlaceBuilding();

            BoltBuildingPlacer.LocalNetworkedBuildingPlaced(data.requester);

            this.health = data.health;
        }
예제 #7
0
        public CreateNetworkedBuilding PackData(BoltEntity requester, bool initiateEvent)
        {
            if (initiateEvent)
            {
                CallPack(this);
            }

            var evnt = CreateNetworkedBuilding.Create(Bolt.GlobalTargets.Others, Bolt.ReliabilityModes.ReliableOrdered);

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