public override void ServerOnRepairStageFinished(IStaticWorldObject worldObject, ICharacter character) { var publicState = GetPublicState(worldObject); var areaPrivateState = LandClaimArea.GetPrivateState(publicState.LandClaimAreaObject); areaPrivateState.IsDestroyedByPlayers = false; }
public bool SharedCanEditOwners(IStaticWorldObject worldObject, ICharacter byOwner) { var area = GetPublicState(worldObject).LandClaimAreaObject; var privateState = LandClaimArea.GetPrivateState(area); // only founder can edit the owners list return(privateState.LandClaimFounder == byOwner.Name); }
public bool SharedCanEditOwners(IStaticWorldObject worldObject, ICharacter byOwner) { var area = GetPublicState(worldObject).LandClaimAreaObject; var privateState = LandClaimArea.GetPrivateState(area); if (privateState.LandClaimFounder == byOwner.Name || CreativeModeSystem.SharedIsInCreativeMode(byOwner)) { // only founder or character in creative mode can edit the owners list return(true); } return(false); }
protected override void ServerOnStaticObjectZeroStructurePoints( WeaponFinalCache weaponCache, ICharacter byCharacter, IWorldObject targetObject) { // do not use default implementation because it will destroy the object automatically //base.ServerOnStaticObjectZeroStructurePoints(weaponCache, targetObject); var worldObject = (IStaticWorldObject)targetObject; var publicState = GetPublicState(worldObject); if (byCharacter != null && (LandClaimSystem.ServerIsOwnedArea(publicState.LandClaimAreaObject, byCharacter) || CreativeModeSystem.SharedIsInCreativeMode(byCharacter))) { // this is the owner of the area or the player is in a creative mode if (byCharacter.SharedGetPlayerSelectedHotbarItemProto() is ProtoItemToolCrowbar) { publicState.ServerTimeForDestruction = 0; Logger.Important( $"Land claim object {targetObject} destroyed by the owner with a crowbar - no destruction timer", byCharacter); this.ServerForceUpdate(worldObject, publicState); return; } } if (byCharacter != null) { var areaPrivateState = LandClaimArea.GetPrivateState(publicState.LandClaimAreaObject); areaPrivateState.IsDestroyedByPlayers = true; } if (publicState.ServerTimeForDestruction.HasValue) { // destruction timer is already set return; } // the land claim structure points is zero - it's broken now - set timer for destruction var timeout = PveSystem.ServerIsPvE ? 0 : this.DestructionTimeout.TotalSeconds; publicState.ServerTimeForDestruction = Server.Game.FrameTime + timeout; Logger.Important($"Timer for destruction set: {targetObject}. Timeout: {timeout}"); this.ServerForceUpdate(worldObject, publicState); }
public override void ServerApplyDecay(IStaticWorldObject worldObject, double deltaTime) { var publicState = GetPublicState(worldObject); if (publicState.StructurePointsCurrent <= 0) { // already awaiting destruction return; } base.ServerApplyDecay(worldObject, deltaTime); if (publicState.StructurePointsCurrent <= 0) { // decayed to the point of starting the destroy timer var areaPrivateState = LandClaimArea.GetPrivateState(publicState.LandClaimAreaObject); areaPrivateState.IsDestroyedByPlayers = false; } }
public override void ServerApplyDecay(IStaticWorldObject worldObject, double deltaTime) { var publicState = GetPublicState(worldObject); if (publicState.StructurePointsCurrent <= 0) { // already awaiting destruction return; } base.ServerApplyDecay(worldObject, deltaTime); if (publicState.StructurePointsCurrent > 0) { return; } // decayed to the point of starting the destroy timer var area = publicState.LandClaimAreaObject; var areaPrivateState = LandClaimArea.GetPrivateState(area); areaPrivateState.IsDestroyedByPlayers = false; var areasGroup = LandClaimSystem.SharedGetLandClaimAreasGroup(area); if (areasGroup is null) { return; } var faction = LandClaimAreasGroup.GetPublicState(areasGroup).ServerFaction; if (faction is null) { return; } var centerTilePosition = LandClaimArea.GetPublicState(area).LandClaimCenterTilePosition; FactionSystem.ServerOnLandClaimDecayed(faction, centerTilePosition); }
public override bool SharedOnDamage( WeaponFinalCache weaponCache, IStaticWorldObject targetObject, double damagePreMultiplier, out double obstacleBlockDamageCoef, out double damageApplied) { if (IsServer) { LandClaimSystem.ServerOnRaid(targetObject.Bounds, weaponCache.Character, isShort: this.IsShortRaidblockOnHit); } var publicState = GetPublicState(targetObject); var previousStructurePoints = publicState.StructurePointsCurrent; if (previousStructurePoints <= 0f) { // already destroyed land claim object (waiting for the destroy timer) obstacleBlockDamageCoef = this.ObstacleBlockDamageCoef; damageApplied = 0; if (IsServer && weaponCache.Character != null) { var areaPrivateState = LandClaimArea.GetPrivateState(publicState.LandClaimAreaObject); areaPrivateState.IsDestroyedByPlayers = true; } return(true); } return(base.SharedOnDamage(weaponCache, targetObject, damagePreMultiplier, out obstacleBlockDamageCoef, out damageApplied)); }
public ObjectLandClaimCanUpgradeCheckResult SharedCanUpgrade( IStaticWorldObject worldObjectLandClaim, IProtoObjectLandClaim protoUpgradedLandClaim, ICharacter character, out IConstructionUpgradeEntryReadOnly upgradeEntry, bool writeErrors = true) { if (!this.SharedCanInteract(character, worldObjectLandClaim, writeToLog: writeErrors)) { upgradeEntry = null; return(ObjectLandClaimCanUpgradeCheckResult.ErrorUnknown); } upgradeEntry = null; foreach (var entry in this.ConfigUpgrade.Entries) { if (entry.ProtoStructure == protoUpgradedLandClaim) { upgradeEntry = entry; break; } } var currentLandClaimArea = GetPublicState(worldObjectLandClaim).LandClaimAreaObject; var founderName = LandClaimArea.GetPrivateState(currentLandClaimArea).LandClaimFounder; var result = ObjectLandClaimCanUpgradeCheckResult.Success; if (upgradeEntry == null) { result = ObjectLandClaimCanUpgradeCheckResult.ErrorUnknown; } if (result == ObjectLandClaimCanUpgradeCheckResult.Success) { if (character.Name != founderName && !CreativeModeSystem.SharedIsInCreativeMode(character)) { result = ObjectLandClaimCanUpgradeCheckResult.ErrorNotFounder; } } if (result == ObjectLandClaimCanUpgradeCheckResult.Success) { // validate player know the tech, have enough items, etc if (!upgradeEntry.CheckRequirementsSatisfied(character)) { upgradeEntry = null; result = ObjectLandClaimCanUpgradeCheckResult.ErrorRequirementsNotSatisfied; } } if (result == ObjectLandClaimCanUpgradeCheckResult.Success) { // check there will be no intersection with other areas var landClaimCenterTilePosition = LandClaimSystem.SharedCalculateLandClaimObjectCenterTilePosition(worldObjectLandClaim); if (!LandClaimSystem.SharedCheckCanPlaceOrUpgradeLandClaimThere( protoUpgradedLandClaim, landClaimCenterTilePosition, character)) { result = ObjectLandClaimCanUpgradeCheckResult.ErrorAreaIntersection; } } if (result == ObjectLandClaimCanUpgradeCheckResult.Success) { if (!InteractionCheckerSystem.SharedHasInteraction(character, worldObjectLandClaim, requirePrivateScope: true)) { result = ObjectLandClaimCanUpgradeCheckResult.ErrorNoActiveInteraction; } } if (result == ObjectLandClaimCanUpgradeCheckResult.Success) { if (LandClaimSystem.SharedIsUnderRaidBlock(character, worldObjectLandClaim)) { // the building is in an area under the raid LandClaimSystem.SharedSendNotificationActionForbiddenUnderRaidblock(character); result = ObjectLandClaimCanUpgradeCheckResult.ErrorUnderRaid; } } if (writeErrors && result != ObjectLandClaimCanUpgradeCheckResult.Success) { Logger.Warning( $"Can\'t upgrade: {worldObjectLandClaim} to {protoUpgradedLandClaim}: error code - {result}", character); } return(result); }