Exemplo n.º 1
0
    public BaseEntity CreateConstruction(
        Construction.Target target,
        bool bNeedsValidPlacement = false)
    {
        GameObject prefab     = GameManager.server.CreatePrefab(this.fullName, Vector3.get_zero(), Quaternion.get_identity(), false);
        bool       flag       = this.UpdatePlacement(prefab.get_transform(), this, ref target);
        BaseEntity baseEntity = prefab.ToBaseEntity();

        if (bNeedsValidPlacement && !flag)
        {
            if (baseEntity.IsValid())
            {
                baseEntity.Kill(BaseNetworkable.DestroyMode.None);
            }
            else
            {
                GameManager.Destroy(prefab, 0.0f);
            }
            return((BaseEntity)null);
        }
        DecayEntity decayEntity = baseEntity as DecayEntity;

        if (Object.op_Implicit((Object)decayEntity))
        {
            decayEntity.AttachToBuilding(target.entity as DecayEntity);
        }
        return(baseEntity);
    }
Exemplo n.º 2
0
    public BaseEntity CreateConstruction(Target target, bool bNeedsValidPlacement = false)
    {
        GameObject gameObject = GameManager.server.CreatePrefab(fullName, Vector3.zero, Quaternion.identity, false);
        bool       flag       = UpdatePlacement(gameObject.transform, this, ref target);
        BaseEntity baseEntity = GameObjectEx.ToBaseEntity(gameObject);

        if (bNeedsValidPlacement && !flag)
        {
            if (BaseEntityEx.IsValid(baseEntity))
            {
                baseEntity.Kill();
            }
            else
            {
                GameManager.Destroy(gameObject);
            }
            return(null);
        }
        DecayEntity decayEntity = baseEntity as DecayEntity;

        if ((bool)decayEntity)
        {
            decayEntity.AttachToBuilding(target.entity as DecayEntity);
        }
        return(baseEntity);
    }
    private void Split(BuildingManager.Building building)
    {
        while (building.HasBuildingBlocks())
        {
            BuildingBlock          buildingBlock = building.buildingBlocks.get_Item(0);
            uint                   newID         = BuildingManager.server.NewBuildingID();
            Action <BuildingBlock> action        = (Action <BuildingBlock>)(b => b.AttachToBuilding(newID));
            buildingBlock.EntityLinkBroadcast <BuildingBlock>(action);
        }
        while (building.HasBuildingPrivileges())
        {
            BuildingPrivlidge buildingPrivlidge   = building.buildingPrivileges.get_Item(0);
            BuildingBlock     nearbyBuildingBlock = buildingPrivlidge.GetNearbyBuildingBlock();
            buildingPrivlidge.AttachToBuilding(Object.op_Implicit((Object)nearbyBuildingBlock) ? nearbyBuildingBlock.buildingID : 0U);
        }
        while (building.HasDecayEntities())
        {
            DecayEntity   decayEntity         = building.decayEntities.get_Item(0);
            BuildingBlock nearbyBuildingBlock = decayEntity.GetNearbyBuildingBlock();
            decayEntity.AttachToBuilding(Object.op_Implicit((Object)nearbyBuildingBlock) ? nearbyBuildingBlock.buildingID : 0U);
        }
        if (!ConVar.AI.nav_carve_use_building_optimization)
        {
            return;
        }
        building.isNavMeshCarvingDirty = true;
        int ticks = 2;

        this.UpdateNavMeshCarver(building, ref ticks, 0);
    }
Exemplo n.º 4
0
    public BaseEntity CreateConstruction(Construction.Target target, bool bNeedsValidPlacement = false)
    {
        GameObject gameObject = GameManager.server.CreatePrefab(this.fullName, Vector3.zero, Quaternion.identity, false);
        bool       flag       = this.UpdatePlacement(gameObject.transform, this, ref target);
        BaseEntity baseEntity = gameObject.ToBaseEntity();

        if (bNeedsValidPlacement && !flag)
        {
            if (!baseEntity.IsValid())
            {
                GameManager.Destroy(gameObject, 0f);
            }
            else
            {
                baseEntity.Kill(BaseNetworkable.DestroyMode.None);
            }
            return(null);
        }
        DecayEntity decayEntity = baseEntity as DecayEntity;

        if (decayEntity)
        {
            decayEntity.AttachToBuilding(target.entity as DecayEntity);
        }
        return(baseEntity);
    }
    private void Split(BuildingManager.Building building)
    {
        uint num;
        uint num1;

        while (building.HasBuildingBlocks())
        {
            BuildingBlock item = building.buildingBlocks[0];
            uint          num2 = BuildingManager.server.NewBuildingID();
            item.EntityLinkBroadcast <BuildingBlock>((BuildingBlock b) => b.AttachToBuilding(num2));
        }
        while (building.HasBuildingPrivileges())
        {
            BuildingPrivlidge buildingPrivlidge   = building.buildingPrivileges[0];
            BuildingBlock     nearbyBuildingBlock = buildingPrivlidge.GetNearbyBuildingBlock();
            if (nearbyBuildingBlock)
            {
                num = nearbyBuildingBlock.buildingID;
            }
            else
            {
                num = 0;
            }
            buildingPrivlidge.AttachToBuilding(num);
        }
        while (building.HasDecayEntities())
        {
            DecayEntity   decayEntity   = building.decayEntities[0];
            BuildingBlock buildingBlock = decayEntity.GetNearbyBuildingBlock();
            if (buildingBlock)
            {
                num1 = buildingBlock.buildingID;
            }
            else
            {
                num1 = 0;
            }
            decayEntity.AttachToBuilding(num1);
        }
        if (AI.nav_carve_use_building_optimization)
        {
            building.isNavMeshCarvingDirty = true;
            int num3 = 2;
            this.UpdateNavMeshCarver(building, ref num3, 0);
        }
    }