示例#1
0
        protected override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
        {
            tileRequirements.Clear()
            //// do these checks if the bomb will have physics!
            //.Add(ConstructionTileRequirements.ValidatorClientOnlyNoCurrentPlayer)
            //.Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyDynamic)
            .Add(new ConstructionTileRequirements.Validator(
                     ConstructionTileRequirements.ErrorNoFreeSpace,
                     c => !ConstructionTileRequirements.TileHasAnyPhysicsObjectsWhere(
                         c.Tile,
                         t =>
            {
                if (!t.PhysicsBody.IsStatic)
                {
                    // allow
                    return(false);
                }

                switch (t.PhysicsBody.AssociatedWorldObject
                        ?.ProtoWorldObject)
                {
                case IProtoObjectDeposit _:                                       // allow deposits
                case ObjectWallDestroyed _:                                       // allow destroyed walls
                    return(false);
                }

                return(true);
            })));
        }
示例#2
0
 protected override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
 {
     tileRequirements
     .Clear()
     // skip this check as it's usually fine to drop the loot if player could stand there
     //.Add(ConstructionTileRequirements.ValidatorNoStaticObjectsExceptFloor)
     // validate no static physics objects there except destroyed walls and opened doors
     .Add(ConstructionTileRequirements.ValidatorSolidGround)
     .Add(ConstructionTileRequirements.ValidatorNotCliffOrSlope)
     .Add(new ConstructionTileRequirements.Validator(
              ConstructionTileRequirements.ErrorNoFreeSpace,
              c => !ConstructionTileRequirements.TileHasAnyPhysicsObjectsWhere(
                  c.Tile,
                  t => t.PhysicsBody.IsStatic
                  // allow destroyed walls physics in the tile
                  && !(t.PhysicsBody.AssociatedWorldObject
                       ?.ProtoWorldObject is ObjectWallDestroyed)
                  // allow opened doors in the tile
                  && !(t.PhysicsBody.AssociatedWorldObject
                       ?.ProtoWorldObject is ProtoObjectDoor &&
                       t.PhysicsBody.AssociatedWorldObject
                       .GetPublicState <ObjectDoorPublicState>().IsOpened))))
     // ensure no other loot containers
     .Add(new ConstructionTileRequirements.Validator(
              // ReSharper disable once CanExtractXamlLocalizableStringCSharp
              "Tile already has a loot container",
              c => !c.Tile.StaticObjects.Any(
                  so => so.ProtoStaticWorldObject is ObjectPlayerLootContainer)));
 }
示例#3
0
        protected sealed override void PrepareConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair,
            ConstructionUpgradeConfig upgrade,
            out ProtoStructureCategory category)
        {
            // Oil pump requires each tile to contain an oil seep.
            // Notice: technically it will be possible to construct one oil pump on two oil seeps if they're nearby,
            // so there should be the oil spawn limitation to avoid that case!
            tileRequirements
            .Clear()
            .Add(ValidatorForPvP)
            .Add(ValidatorForPvE)
            .Add(ConstructionTileRequirements.BasicRequirements)
            .Add(ConstructionTileRequirements.ValidatorClientOnlyNoCurrentPlayer)
            .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyDynamic)
            .Add(ConstructionTileRequirements.ErrorNoFreeSpace,
                 c => !ConstructionTileRequirements.TileHasAnyPhysicsObjectsWhere(
                     c.Tile,
                     o => o.PhysicsBody.IsStatic &&
                     !(o.PhysicsBody.AssociatedWorldObject?.ProtoWorldObject
                       is ObjectDepositOilSeep)))
            .Add(ConstructionTileRequirements.ErrorNoFreeSpace,
                 c => c.Tile.StaticObjects.All(o => o.ProtoWorldObject is ObjectDepositOilSeep))
            .Add(ConstructionTileRequirements.ValidatorNotRestrictedArea)
            .Add(LandClaimSystem.ValidatorIsOwnedOrFreeArea);

            this.PrepareConstructionConfig(build,
                                           repair,
                                           out category);
        }
示例#4
0
        protected override void PrepareConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair,
            ConstructionUpgradeConfig upgrade,
            out ProtoStructureCategory category)
        {
            // Lithium salt extractor requires each tile to contain a geothermal spring.
            tileRequirements
            .Clear()
            .Add(ValidatorForPvP)
            .Add(ValidatorForPvE)
            .Add(ConstructionTileRequirements.BasicRequirements)
            .Add(ConstructionTileRequirements.ValidatorClientOnlyNoCurrentPlayer)
            .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyDynamic)
            .Add(ConstructionTileRequirements.ErrorNoFreeSpace,
                 c => !ConstructionTileRequirements.TileHasAnyPhysicsObjectsWhere(
                     c.Tile,
                     t => t.PhysicsBody.IsStatic &&
                     !(t.PhysicsBody.AssociatedWorldObject?.ProtoWorldObject is
                       ObjectDepositGeothermalSpring)))
            .Add(ConstructionTileRequirements.ErrorNoFreeSpace,
                 c => c.Tile.StaticObjects.All(o => o.ProtoWorldObject is ObjectDepositGeothermalSpring))
            .Add(ConstructionTileRequirements.ValidatorNotRestrictedArea)
            .Add(LandClaimSystem.ValidatorIsOwnedOrFreeArea);

            this.PrepareConstructionConfig(build, repair, out category);
        }
示例#5
0
        protected sealed override void PrepareConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair,
            ConstructionUpgradeConfig upgrade,
            out ProtoStructureCategory category)
        {
            category = GetCategory <StructureCategoryBuildings>();

            // can build only if there is no floor or floor of different prototype
            var validatorNoFloorOfTheSameType
                = new ConstructionTileRequirements.Validator(
                      ConstructionTileRequirements.ErrorCannotBuildOnFloor,
                      c => c.Tile.StaticObjects.All(
                          o => o.ProtoStaticWorldObject != this));

            // Tile requirements is not overridable for floors implementations:
            // require solid ground, no built floor, no static (non-structure) objects, no farms
            tileRequirements
            .Clear()
            .Add(ConstructionTileRequirements.BasicRequirements)
            .Add(ConstructionTileRequirements.ValidatorNoStaticObjectsExceptPlayersStructures)
            .Add(ConstructionTileRequirements.ValidatorNoFarmPlot)
            .Add(validatorNoFloorOfTheSameType)
            .Add(ConstructionTileRequirements.ValidatorNotRestrictedArea)
            .Add(ConstructionTileRequirements.ValidatorNoNpcsAround)
            .Add(ConstructionTileRequirements.ValidatorNoPlayersNearby)
            .Add(LandClaimSystem.ValidatorIsOwnedLandInPvEOnly)
            .Add(LandClaimSystem.ValidatorNoRaid)
            .Add(LandClaimSystem.ValidatorNoShieldProtection);

            build.StagesCount = 1;
            this.PrepareFloorConstructionConfig(build, repair);
        }
 protected override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
 {
     tileRequirements.Clear()
     .Add("No other platforms allowed",
          c => c.Tile.StaticObjects.All(
              o => o.ProtoStaticWorldObject.Kind != StaticObjectKind.Platform));
 }
示例#7
0
        protected sealed override void PrepareConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair,
            ConstructionUpgradeConfig upgrade,
            out ProtoStructureCategory category)
        {
            tileRequirements
            .Clear()
            .Add(ConstructionTileRequirements.DefaultForPlayerStructuresOwnedOrFreeLand)
            // land-claim specific requirements
            .Add(LandClaimSystem.ValidatorNewLandClaimNoLandClaimIntersectionsWithShieldProtection)
            .Add(LandClaimSystem.ValidatorNewLandClaimNoLandClaimIntersections)
            .Add(LandClaimSystem.ValidatorCheckCharacterLandClaimAmountLimit)
            .Add(LandClaimSystem.ValidatorNewLandClaimNoLandClaimIntersectionsWithDemoPlayers)
            .Add(LandClaimSystem.ValidatorNewLandClaimNoLandClaimsTooClose)
            .Add(LandClaimSystem.ValidatorCheckLandClaimDepositRequireXenogeology)
            .Add(LandClaimSystem.ValidatorCheckLandClaimDepositCooldown)
            .Add(LandClaimSystem.ValidatorCheckLandClaimBaseSizeLimitNotExceeded)
            .Add(LandClaimSystem.ValidatorNewLandClaimSafeStorageCapacityNotExceeded)
            .Add(ObjectMineralPragmiumSource.ValidatorCheckNoPragmiumSourceNearbyOnPvE);

            this.PrepareLandClaimConstructionConfig(tileRequirements, build, repair, upgrade, out category);

            var landClaimSize = this.LandClaimSize;

            Api.Assert(landClaimSize % 2 == 0, "Land claim size should be an even number");
        }
 protected override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
 {
     tileRequirements.Clear()
     //// do these checks if the bomb will have physics!
     //.Add(ConstructionTileRequirements.ValidatorClientOnlyNoCurrentPlayer)
     //.Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyDynamic)
     .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyStatic);
 }
 protected override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
 {
     tileRequirements
     .Clear()
     .Add(ConstructionTileRequirements.ValidatorNoStaticObjectsExceptFloor)
     .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyStatic)
     // ensure no other loot containers
     .Add(new ConstructionTileRequirements.Validator(
              // ReSharper disable once CanExtractXamlLocalizableStringCSharp
              "Tile already has a loot container",
              c => !c.Tile.StaticObjects.Any(
                  so => so.ProtoStaticWorldObject is ObjectPlayerLootContainer)));
 }
示例#10
0
 protected override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
 {
     tileRequirements
     .Clear()
     .Add(ErrorRequiresFarmPlot,
          c => c.Tile.StaticObjects.Any(_ => _.ProtoStaticWorldObject is IProtoObjectFarm))
     .Add(ConstructionTileRequirements.BasicRequirements)
     .Add(ConstructionTileRequirements.ErrorNoFreeSpace,
          // ensure there are no static physics objects (other than farm)
          c => !ConstructionTileRequirements
          .TileHasAnyPhysicsObjectsWhere(
              c.Tile,
              o => o.PhysicsBody.IsStatic &&
              !(o.PhysicsBody.AssociatedWorldObject?.ProtoWorldObject
                is IProtoObjectFarm)));
 }
        protected sealed override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
        {
            var configBuild   = new ConstructionStageConfig();
            var configRepair  = new ConstructionStageConfig();
            var configUpgrade = new ConstructionUpgradeConfig();

            tileRequirements.Clear()
            .Add(ConstructionTileRequirements.DefaultForPlayerStructures);

            this.PrepareConstructionConfig(
                tileRequirements,
                configBuild,
                configRepair,
                configUpgrade,
                out var category);

            configBuild.ApplyRates(StructureConstants.BuildItemsCountMultiplier);
            configUpgrade.ApplyRates(StructureConstants.BuildItemsCountMultiplier);
            configRepair.ApplyRates(StructureConstants.RepairItemsCountMultiplier);

            this.Category = category
                            ?? throw new Exception(
                                      "Structure category is not set during "
                                      + nameof(this.PrepareConstructionConfig)
                                      + " call");

            foreach (var upgradeEntry in configUpgrade.Entries)
            {
                if (upgradeEntry.RequiredItems.Count > 4)
                {
                    // we don't allow more than 4 items for upgrades (the upgrade UI space is strictly limited)
                    throw new Exception(this.ShortId
                                        + " requires more than 4 items to upgrade to "
                                        + upgradeEntry.ProtoStructure.ShortId
                                        + ". Max 4 items allowed");
                }
            }

            if (configRepair.IsAllowed)
            {
                this.ValidateRepairConfig(configRepair, configBuild);
            }

            this.ConfigBuild   = configBuild;
            this.ConfigRepair  = configRepair;
            this.ConfigUpgrade = configUpgrade;
        }
 protected override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
 {
     tileRequirements
     .Clear()
     .Add(new ConstructionTileRequirements.Validator(ConstructionTileRequirements.ErrorNoFreeSpace,
                                                     c => c.Tile.StaticObjects.All(
                                                         _ => _.ProtoStaticWorldObject.Kind
                                                         == StaticObjectKind.Floor)))
     // ensure no static physical objects at tile
     .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyStatic)
     // ensure no other static objects (including loot)
     .Add(new ConstructionTileRequirements.Validator(
              // ReSharper disable once CanExtractXamlLocalizableStringCSharp
              "Tile already has a loot container",
              c => !c.Tile.StaticObjects.Any(
                  so => so.ProtoStaticWorldObject is ObjectPlayerLootContainer)));
 }
        protected sealed override void PrepareDecorationConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair)
        {
            tileRequirements
            .Clear()
            .Add(ConstructionTileRequirements.BasicRequirements)
            .Add(ConstructionTileRequirements.ValidatorNoStaticObjectsExceptPlayersStructures)
            .Add(ConstructionTileRequirements.ValidatorNoFarmPlot)
            .Add(ValidatorNoFloorDecoration)
            .Add(ConstructionTileRequirements.ValidatorNotRestrictedArea)
            .Add(ConstructionTileRequirements.ValidatorNoNpcsAround)
            .Add(LandClaimSystem.ValidatorIsOwnedOrFreeArea)
            .Add(LandClaimSystem.ValidatorNoRaid);

            this.PrepareFloorDecorationConstructionConfig(build, repair);
        }
示例#14
0
        protected override void PrepareConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair,
            ConstructionUpgradeConfig upgrade,
            out ProtoStructureCategory category)
        {
            tileRequirements.Clear()
            .Add(ConstructionTileRequirements.DefaultForPlayerStructuresOwnedOrFreeLand);

            category = GetCategory <StructureCategoryIndustry>();

            build.StagesCount          = 5;
            build.StageDurationSeconds = BuildDuration.Short;
            build.AddStageRequiredItem <ItemPlanks>(count: 5);

            repair.StagesCount          = 10;
            repair.StageDurationSeconds = BuildDuration.Short;
            repair.AddStageRequiredItem <ItemPlanks>(count: 1);
        }
示例#15
0
        protected sealed override void PrepareFarmConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair)
        {
            tileRequirements
            .Clear()
            .Add(ConstructionTileRequirements.BasicRequirements)
            .Add(ErrorSoilNotSuitable, c => c.Tile.ProtoTile is IProtoTileFarmAllowed)
            .Add(ConstructionTileRequirements.ValidatorNoFarmPlot)
            .Add(ConstructionTileRequirements.ValidatorNoFloor)
            .Add(ConstructionTileRequirements.ValidatorNoStaticObjectsExceptFloor)
            .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyStatic)
            .Add(ConstructionTileRequirements.ValidatorNotRestrictedArea)
            .Add(ConstructionTileRequirements.ValidatorNoNpcsAround)
            .Add(LandClaimSystem.ValidatorIsOwnedOrFreeArea)
            .Add(LandClaimSystem.ValidatorNoRaid);

            this.PrepareFarmPlotConstructionConfig(tileRequirements, build, repair);
        }
示例#16
0
        protected override void PrepareConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair,
            ConstructionUpgradeConfig upgrade,
            out ProtoStructureCategory category)
        {
            category = GetCategory <StructureCategoryIndustry>();

            // Oil pump requires each tile to contain an oil seep.
            // Notice: technically it will be possible to construct one oil pump on two oil seeps if they're nearby,
            // so there should be the oil spawn limitation to avoid that case!
            tileRequirements
            .Clear()
            .Add(ErrorRequiresOilSeep,
                 c => c.Tile.StaticObjects.Any(_ => _.ProtoStaticWorldObject is ObjectDepositOilSeep))
            .Add(ConstructionTileRequirements.BasicRequirements)
            .Add(ConstructionTileRequirements.ValidatorClientOnlyNoCurrentPlayer)
            .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyDynamic)
            .Add(ConstructionTileRequirements.ErrorNoFreeSpace,
                 c => !ConstructionTileRequirements.TileHasAnyPhysicsObjectsWhere(
                     c.Tile,
                     o => o.PhysicsBody.IsStatic &&
                     !(o.PhysicsBody.AssociatedWorldObject?.ProtoWorldObject
                       is ObjectDepositOilSeep)))
            .Add(ConstructionTileRequirements.ValidatorNotRestrictedArea)
            .Add(LandClaimSystem.ValidatorIsOwnedOrFreeArea);

            build.StagesCount          = 10;
            build.StageDurationSeconds = BuildDuration.Short;
            build.AddStageRequiredItem <ItemIngotSteel>(count: 20);
            build.AddStageRequiredItem <ItemIngotCopper>(count: 15);
            build.AddStageRequiredItem <ItemCement>(count: 25);

            repair.StagesCount          = 10;
            repair.StageDurationSeconds = BuildDuration.Short;
            repair.AddStageRequiredItem <ItemIngotSteel>(count: 5);
            repair.AddStageRequiredItem <ItemIngotCopper>(count: 2);
        }
        protected override void PrepareConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair,
            ConstructionUpgradeConfig upgrade,
            out ProtoStructureCategory category)
        {
            tileRequirements.Clear()
            .Add(ConstructionTileRequirements.ValidatorNoStaticObjectsExceptFloor)
            .AddClientOnly(ConstructionTileRequirements.ValidatorClientOnlyNoCurrentPlayer)
            .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyDynamic)
            .Add(ConstructionTileRequirements.ValidatorNotRestrictedArea)
            .Add(ConstructionTileRequirements.ValidatorNoNpcsAround)
            .Add(ConstructionTileRequirements.ValidatorNoPlayersNearby)
            .Add(LandClaimSystem.ValidatorIsOwnedLandInPvEOnly)
            .Add(LandClaimSystem.ValidatorNoRaid)
            .Add(LandClaimSystem.ValidatorNoShieldProtection);

            this.PrepareConstructionConfigSprinkler(build,
                                                    repair,
                                                    upgrade,
                                                    out category);
        }
示例#18
0
        protected override void PrepareConstructionConfig(
            ConstructionTileRequirements tileRequirements,
            ConstructionStageConfig build,
            ConstructionStageConfig repair,
            ConstructionUpgradeConfig upgrade,
            out ProtoStructureCategory category)
        {
            category = GetCategory <StructureCategoryIndustry>();

            // Lithium salt extractor requires each tile to contain a geothermal spring.
            tileRequirements
            .Clear()
            .Add(ErrorRequiresGeothermalSpring,
                 c => c.Tile.StaticObjects.Any(_ => _.ProtoStaticWorldObject is ObjectDepositGeothermalSpring))
            .Add(ConstructionTileRequirements.BasicRequirements)
            .Add(ConstructionTileRequirements.ValidatorClientOnlyNoCurrentPlayer)
            .Add(ConstructionTileRequirements.ValidatorNoPhysicsBodyDynamic)
            .Add(ConstructionTileRequirements.ErrorNoFreeSpace,
                 c => !ConstructionTileRequirements.TileHasAnyPhysicsObjectsWhere(
                     c.Tile,
                     t => t.PhysicsBody.IsStatic &&
                     !(t.PhysicsBody.AssociatedWorldObject?.ProtoWorldObject is
                       ObjectDepositGeothermalSpring)))
            .Add(ConstructionTileRequirements.ValidatorNotRestrictedArea)
            .Add(LandClaimSystem.ValidatorIsOwnedOrFreeArea);

            build.StagesCount          = 10;
            build.StageDurationSeconds = BuildDuration.Short;
            build.AddStageRequiredItem <ItemIngotSteel>(count: 20);
            build.AddStageRequiredItem <ItemIngotCopper>(count: 15);
            build.AddStageRequiredItem <ItemCement>(count: 25);

            repair.StagesCount          = 10;
            repair.StageDurationSeconds = BuildDuration.Short;
            repair.AddStageRequiredItem <ItemIngotSteel>(count: 5);
            repair.AddStageRequiredItem <ItemIngotCopper>(count: 2);
        }
示例#19
0
 protected override void PrepareTileRequirements(ConstructionTileRequirements tileRequirements)
 {
     tileRequirements.Clear();
 }