Exemple #1
0
        void RpcBuildNew(Vector3 position, Quaternion rotation, BuildingPartType partType)
        {
#if SERVER
            var buildingManager = SystemProvider.GetSystem <IBuildingSystem>(gameObject);

            var newBuilding = buildingManager.CreateBuilding(_builderTypeExtension.buildingType, position, rotation);
            newBuilding.AddPart(partType, null);
            newBuilding.Rebuild();
#endif
        }
Exemple #2
0
 void UpdatePartType()
 {
     foreach (var binding in _bindings)
     {
         if (Input.GetKeyDown(binding.key))
         {
             _currentPartType = binding.partType;
             RebuildBlueprint();
         }
     }
 }
 public GameObject GetPrefabForPartType(BuildingPartType partType)
 {
     foreach (var partT in _partTypes)
     {
         if (partT.partType == partType)
         {
             return(partT.prefab);
         }
     }
     return(null);
 }
        public int GetNumChildrenForPartType(BuildingType type, BuildingPartType partType)
        {
            var prefab = type.GetPrefabForPartType(partType);

            if (prefab == null)
            {
                return(0);
            }

            var slots = prefab.GetComponentsInChildren <BuildingSlot>();

            return(slots.Length);
        }
Exemple #5
0
        void RpcBuild(Replica buildingReplica, BuildingPartType partType, BuildingSlotType buildingSlotType, Vector3 slotPosition)
        {
            var building = buildingReplica.GetComponent <Building>();

            float distance = 0;
            var   slot     = building.GetClosestSlot(slotPosition, buildingSlotType, true, out distance);

            //#TODO check distance

            Assert.IsNotNull(slot);

            building.AddPart(partType, slot);
            building.Rebuild();
        }
Exemple #6
0
        public void AddPart(BuildingPartType type, BuildingSlot slot)
        {
            var partPosition = slot != null ? slot.transform.position : transform.position;
            var partRotation = slot != null ? slot.transform.rotation : transform.rotation;

            if (_data.parts == null)
            {
                _data.parts = new List <Part>();
            }

            var newPart = new Part {
                type     = type,
                position = partPosition,
                rotation = partRotation
            };

            _data.parts.Add(newPart);


            //#TODO extend bounds
        }