예제 #1
0
 public bool IsValidBuildPos(Vector3 a_pos, int a_buildingType)
 {
     foreach (DictionaryEntry building in m_buildings)
     {
         RemoteBuilding remoteBuilding = (RemoteBuilding)building.Value;
         if (null != remoteBuilding && !remoteBuilding.m_isStatic)
         {
             float sqrMagnitude = (remoteBuilding.transform.position - a_pos).sqrMagnitude;
             if ((!remoteBuilding.m_isMine && Buildings.IsDoor(remoteBuilding.m_type) && sqrMagnitude < 25f) || sqrMagnitude < 0.202499986f)
             {
                 return(false);
             }
         }
     }
     if (!Buildings.IsHarmless(a_buildingType))
     {
         SpecialArea[] specialAreas = m_specialAreas;
         foreach (SpecialArea specialArea in specialAreas)
         {
             if (null != specialArea && (specialArea.m_type == eAreaType.noBuilding || specialArea.m_type == eAreaType.noPvp) && (specialArea.transform.position - a_pos).sqrMagnitude < specialArea.m_radius * specialArea.m_radius)
             {
                 return(false);
             }
         }
     }
     return(Buildings.IsDoor(a_buildingType) || !Raycaster.BuildingSphereCast(a_pos));
 }
예제 #2
0
    public bool CreateBuilding(int a_type, Vector3 a_pos, int a_ownerPid = 0, float a_yRot = 0f, int a_health = 100, bool a_isNew = true)
    {
        bool flag = false == a_isNew;

        if (!flag)
        {
            ServerBuilding serverBuilding = this.GetNearestPlayerBuilding(a_pos, -1);
            if (null == serverBuilding || (serverBuilding.transform.position - a_pos).sqrMagnitude > 0.20249999f)
            {
                serverBuilding = ((Buildings.IsCollider(a_type) && a_ownerPid != 0) ? this.GetNearestPlayerBuilding(a_pos, a_ownerPid) : null);
                if ((null == serverBuilding || !Buildings.IsDoor(serverBuilding.m_type) || (serverBuilding.transform.position - a_pos).sqrMagnitude > 25f) && (Buildings.IsDoor(a_type) || !Raycaster.BuildingSphereCast(a_pos)) && 0.8f < Util.GetTerrainHeight(a_pos))
                {
                    flag = true;
                }
            }
        }
        if (flag)
        {
            GameObject gameObject = (GameObject)Resources.Load("buildings/building_" + a_type);
            if (null != gameObject)
            {
                GameObject      gameObject2         = (GameObject)UnityEngine.Object.Instantiate(gameObject, a_pos, Quaternion.Euler(0f, a_yRot, 0f));
                ServerBuilding  component           = gameObject2.GetComponent <ServerBuilding>();
                NavMeshObstacle componentInChildren = gameObject2.GetComponentInChildren <NavMeshObstacle>();
                if (null != componentInChildren)
                {
                    componentInChildren.carving = this.m_carveNavMesh;
                }
                if (null != component)
                {
                    component.Init(this.m_server, a_type, a_ownerPid, a_health, a_isNew);
                    this.m_buildings.Add(component);
                }
                else
                {
                    Debug.Log("BuildingManager.cs: ERROR: Building without ServerBuilding.cs script spawned!");
                }
            }
        }
        return(flag);
    }