Example #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();
            }
        }
Example #2
0
        void Awake()
        {
            uConstruct.Core.Saving.BuildingGroupSaveData.OnBuildingLoadedEvent += (BaseBuilding building) =>
            {
                BoltBuilding boltBuilding = (BoltBuilding)building;

                if (boltBuilding != null)
                {
                    entities.Add(boltBuilding);
                    boltBuilding.networkedID = entities.Count;
                }
            };
        }
Example #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);
            }
        }
Example #4
0
        public override void DestroyBuilding(BaseBuilding building, RaycastHit hit)
        {
            BoltBuilding boltBuilding = (BoltBuilding)building;

            if(boltBuilding == null)
            {
                base.DestroyBuilding(building,hit);
                return;
            }

            var evnt = UpdateNetworkedBuilding.Create(Bolt.GlobalTargets.OnlyServer, Bolt.ReliabilityModes.ReliableOrdered);
            evnt.buildingUID = boltBuilding.networkedID;
            evnt.health = 0;
            evnt.Send();
        }