public string Execute(ushort x, ushort y) { LandClaimSystem.ServerOnRaid(new RectangleInt(x, y, 1, 1), byCharacter: null, forceEvenIfNoCharacter: true); return(null); }
public string Execute(ushort x, ushort y, double durationMultiplier = 1.0) { durationMultiplier = MathHelper.Clamp(durationMultiplier, 0.01, 1); LandClaimSystem.ServerOnRaid(new RectangleInt(x, y, 1, 1), byCharacter: null, isStructureDestroyed: true, forceEvenIfNoCharacter: true, durationMultiplier); return(null); }
private void ServerExplode(IStaticWorldObject worldObject, ICharacter character) { try { Logger.Important(worldObject + " exploded"); this.ServerSendObjectDestroyedEvent(worldObject); ExplosionHelper.ServerExplode( character: character, protoExplosive: this, protoWeapon: null, explosionPreset: this.ExplosionPreset, epicenterPosition: worldObject.TilePosition.ToVector2D() + this.Layout.Center, damageDescriptionCharacters: this.damageDescriptionCharacters, physicsSpace: worldObject.PhysicsBody.PhysicsSpace, executeExplosionCallback: this.ServerExecuteExplosion); if (this.IsActivatesRaidModeForLandClaim) { var explosionRadius = (int)Math.Ceiling(this.DamageRadius); var bounds = new RectangleInt(x: worldObject.TilePosition.X - explosionRadius, y: worldObject.TilePosition.Y - explosionRadius, width: 2 * explosionRadius, height: 2 * explosionRadius); if (RaidingProtectionSystem.SharedCanRaid(bounds, showClientNotification: false)) { // try activate the raidblock LandClaimSystem.ServerOnRaid(bounds, character); } else { // Raiding is not possible now due to raiding window // Find if there is any land claim and in that case notify nearby players // that the damage to objects there were not applied. if (LandClaimSystem.SharedIsLandClaimedByAnyone(bounds)) { using var tempPlayers = Api.Shared.GetTempList <ICharacter>(); Server.World.GetScopedByPlayers(worldObject, tempPlayers); RaidingProtectionSystem.ServerNotifyShowNotificationRaidingNotAvailableNow( tempPlayers.AsList()); } } } } finally { Server.World.DestroyObject(worldObject); } }
protected override void ServerOnStaticObjectZeroStructurePoints( WeaponFinalCache weaponCache, ICharacter byCharacter, IWorldObject targetObject) { base.ServerOnStaticObjectZeroStructurePoints(weaponCache, byCharacter, targetObject); if (weaponCache != null) { // door was destroyed (and not deconstructed by a crowbar or any other means) LandClaimSystem.ServerOnRaid(((IStaticWorldObject)targetObject).Bounds, byCharacter); } }
protected override void ServerOnStaticObjectDamageApplied( WeaponFinalCache weaponCache, IStaticWorldObject targetObject, float previousStructurePoints, float currentStructurePoints) { LandClaimSystem.ServerOnRaid(targetObject.Bounds, weaponCache.Character); base.ServerOnStaticObjectDamageApplied(weaponCache, targetObject, previousStructurePoints, currentStructurePoints); }
protected override void ServerOnStaticObjectZeroStructurePoints( WeaponFinalCache weaponCache, ICharacter byCharacter, IWorldObject targetObject) { var tilePosition = targetObject.TilePosition; base.ServerOnStaticObjectZeroStructurePoints(weaponCache, byCharacter, targetObject); if (weaponCache != null) { // wall was destroyed (and not deconstructed by a crowbar or any other means) ObjectWallDestroyed.ServerSpawnDestroyedWall(tilePosition, this); LandClaimSystem.ServerOnRaid(((IStaticWorldObject)targetObject).Bounds, byCharacter); } }
private void ServerExplode(IStaticWorldObject worldObject, ICharacter character) { Logger.Important(worldObject + " exploded"); this.ServerSendObjectDestroyedEvent(worldObject); ExplosionHelper.ServerExplode( character: character, protoObjectExplosive: this, explosionPreset: this.ExplosionPreset, epicenterPosition: worldObject.TilePosition.ToVector2D() + this.Layout.Center, damageDescriptionCharacters: this.damageDescriptionCharacters, physicsSpace: worldObject.PhysicsBody.PhysicsSpace, executeExplosionCallback: this.ServerExecuteExplosion); Server.World.DestroyObject(worldObject); LandClaimSystem.ServerOnRaid(worldObject.TilePosition, this.DamageRadius, character); }
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)); }
private void ServerExplode(IItem item) { Server.Items.DestroyItem(item); // explode a primitive bomb in player position var character = item.Container.OwnerAsCharacter; if (character is null) { return; } var characterPublicState = character.GetPublicState <PlayerCharacterPublicState>(); if (!characterPublicState.IsDead) { // ensure the wearer is killed by the explosion characterPublicState.CurrentStats.ServerSetHealthCurrent(0); } var targetPosition = character.Position; var protoBomb = ProtoObjectBomb; SharedExplosionHelper.ServerExplode( character: character, protoExplosive: protoBomb, protoWeapon: null, explosionPreset: protoBomb.ExplosionPreset, epicenterPosition: targetPosition, damageDescriptionCharacters: protoBomb.DamageDescriptionCharacters, physicsSpace: Server.World.GetPhysicsSpace(), executeExplosionCallback: protoBomb.ServerExecuteExplosion); // notify all characters about the explosion using var charactersObserving = Api.Shared.GetTempList <ICharacter>(); const byte explosionEventRadius = 40; Server.World.GetCharactersInRadius(targetPosition.ToVector2Ushort(), charactersObserving, radius: explosionEventRadius, onlyPlayers: true); this.CallClient(charactersObserving.AsList(), _ => _.ClientRemote_OnExplosion(targetPosition)); // activate the raidblock if possible (the code is similar to ProtoObjectEplosive) var explosionRadius = (int)Math.Ceiling(protoBomb.DamageRadius); var bounds = new RectangleInt(x: (int)Math.Round(character.Position.X - explosionRadius), y: (int)Math.Round(character.Position.Y - explosionRadius), width: 2 * explosionRadius, height: 2 * explosionRadius); if (RaidingProtectionSystem.SharedCanRaid(bounds, showClientNotification: false)) { // try activate the raidblock LandClaimSystem.ServerOnRaid(bounds, character, isStructureDestroyed: false); } else { // Raiding is not possible now due to raiding window // Find if there is any land claim and in that case notify nearby players // that the damage to objects there was not applied. if (LandClaimSystem.SharedIsLandClaimedByAnyone(bounds)) { using var tempPlayers = Api.Shared.GetTempList <ICharacter>(); Server.World.GetScopedByPlayers(character, tempPlayers); RaidingProtectionSystem.ServerNotifyShowNotificationRaidingNotAvailableNow( tempPlayers.AsList()); } } }