Skip to content
Merged

p31_1 #492

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Perpetuum/Modules/DrillerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ private void CheckEnablerEffect(MaterialInfo materialInfo)
return;
}

bool containsEnablerEffect = ParentRobot.EffectHandler.ContainsEffect(EffectCategory.effcat_pbs_mining_tower_effect);

bool containsEnablerEffect = ParentRobot.EffectHandler.ContainsEffect(EffectCategory.effcat_pbs_mining_tower_effect) ||
(ParentRobot is RemoteControlledCreature rcu &&
rcu.CommandRobot is Player player &&
player.EffectHandler.ContainsEffect(EffectCategory.effcat_pbs_mining_tower_effect));
containsEnablerEffect.ThrowIfFalse(ErrorCodes.MiningEnablerEffectRequired);
}
}
Expand Down
360 changes: 238 additions & 122 deletions src/Perpetuum/Services/Channels/ChatCommands/AdminCommandHandlers.cs

Large diffs are not rendered by default.

74 changes: 54 additions & 20 deletions src/Perpetuum/Services/RiftSystem/Rift.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Perpetuum.Deployers;
using Perpetuum.EntityFramework;
using Perpetuum.ExportedTypes;
using Perpetuum.Log;
using Perpetuum.Players;
Expand All @@ -13,6 +9,11 @@
using Perpetuum.Zones.Blobs.BlobEmitters;
using Perpetuum.Zones.NpcSystem.Presences;
using Perpetuum.Zones.Teleporting.Strategies;
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Perpetuum.Services.RiftSystem
{
Expand All @@ -38,6 +39,19 @@ public virtual void UseItem(Player player)
player.HasPvpEffect.ThrowIfTrue(ErrorCodes.CantBeUsedInPvp);
player.CurrentPosition.IsInRangeOf3D(CurrentPosition, 8).ThrowIfFalse(ErrorCodes.TeleportOutOfRange);
}

protected override bool IsHostileFor(Unit unit)
{
return unit.IsHostile(this);
}

public override void AcceptVisitor(IEntityVisitor visitor)
{
if (!TryAcceptVisitor(this, visitor))
{
base.AcceptVisitor(visitor);
}
}
}

/// <summary>
Expand Down Expand Up @@ -80,7 +94,9 @@ public void SetConfig(CustomRiftConfig riftConfig)
RiftConfig = riftConfig;
// Only set despawner if config is despawning
if (RiftConfig.IsDespawning)
{
SetDespawnTime(RiftConfig.Lifespan);
}
}

public void SetTarget(IZone zone, Position position)
Expand All @@ -89,7 +105,7 @@ public void SetTarget(IZone zone, Position position)
TargetPosition = position;
}

private bool HasTarget { get { return TargetZone != null && !TargetPosition.Equals(Position.Empty); } }
private bool HasTarget => TargetZone != null && !TargetPosition.Equals(Position.Empty);

private bool IsUsageExceeded()
{
Expand All @@ -99,7 +115,9 @@ private bool IsUsageExceeded()
private void IncrementUsage()
{
if (!RiftConfig.InfiniteUses)
{
uses++;
}
}

private bool IsExcluded(Player player)
Expand All @@ -116,14 +134,16 @@ public override void UseItem(Player player)

IsExcluded(player).ThrowIfTrue(ErrorCodes.RobotWrongType);

var teleport = _teleportStrategyFactories.TeleportToAnotherZoneFactory(TargetZone);
TeleportToAnotherZone teleport = _teleportStrategyFactories.TeleportToAnotherZoneFactory(TargetZone);
teleport.TargetPosition = TargetPosition;
teleport.DoTeleportAsync(player);
_ = teleport.DoTeleportAsync(player);

IncrementUsage();

if (IsUsageExceeded())
{
Kill();
}
}
}

Expand Down Expand Up @@ -152,7 +172,7 @@ public RandomRiftPortal(ITeleportStrategyFactories teleportStrategyFactories)

protected override void OnEnterZone(IZone zone, ZoneEnterType enterType)
{
var rift = Zone.Units.OfType<Rift>().RandomElement();
Rift rift = Zone.Units.OfType<Rift>().RandomElement();
if (rift != null)
{
_targetPosition = rift.CurrentPosition;
Expand All @@ -165,11 +185,11 @@ public override void UseItem(Player player)
{
base.UseItem(player);

var teleport = _teleportStrategyFactories.TeleportWithinZoneFactory();
TeleportWithinZone teleport = _teleportStrategyFactories.TeleportWithinZoneFactory();
teleport.TargetPosition = _targetPosition;
teleport.ApplyTeleportSickness = true;
teleport.ApplyInvulnerable = true;
teleport.DoTeleportAsync(player);
_ = teleport.DoTeleportAsync(player);
}
}

Expand All @@ -188,17 +208,23 @@ public class RiftActivator : ItemDeployerBase
{
public override void Deploy(IZone zone, Player player)
{
var rift = player.GetUnitsWithinRange<Rift>(5).FirstOrDefault();
Rift rift = player.GetUnitsWithinRange<Rift>(5).FirstOrDefault();
if (rift == null)
{
throw new PerpetuumException(ErrorCodes.RiftOutOfRange);
}

if (ED.Tier.level > rift.MaxTAPLevel)
{
throw new PerpetuumException(ErrorCodes.RiftLevelMismatch);
}

if (zone is StrongHoldZone)
{
throw new PerpetuumException(ErrorCodes.ItemNotUsable);
}

var info = new RiftNpcGroupInfo();
RiftNpcGroupInfo info = new RiftNpcGroupInfo();
Debug.Assert(DeployableItemEntityDefault.Config.npcPresenceId != null, "DeployableItemEntityDefault.Config.npcPresenceId != null");
info.presenceID = (int)DeployableItemEntityDefault.Config.npcPresenceId;
Debug.Assert(DeployableItemEntityDefault.Config.lifeTime != null, "DeployableItemEntityDefault.Config.lifeTime != null");
Expand All @@ -208,11 +234,13 @@ public override void Deploy(IZone zone, Player player)
info.ownerPlayer = player;

if (!rift.TryActivate(info))
{
throw new PerpetuumException(ErrorCodes.WTFErrorMedicalAttentionSuggested);
}

LogTransaction(player, this);

var seei = new SummonEggEventInfo(player, DeployableItemEntityDefault.Definition, player.CurrentPosition);
SummonEggEventInfo seei = new SummonEggEventInfo(player, DeployableItemEntityDefault.Definition, player.CurrentPosition);
player.MissionHandler.EnqueueMissionEventInfo(seei);
}
}
Expand Down Expand Up @@ -247,21 +275,27 @@ protected override void OnUpdate(TimeSpan time)

public bool TryActivate(RiftNpcGroupInfo info)
{
var zone = Zone;
IZone zone = Zone;
if (zone == null)
{
return false;
}

if (zone is StrongHoldZone)
{
return false;
}

if (Interlocked.CompareExchange(ref _activated, 1, 0) == 1)
{
return false;
}

zone.CreateBeam(BeamType.npc_egg_beam, builder => builder.WithPosition(CurrentPosition).WithDuration(6000));

Task.Delay(6000).ContinueWith(t =>
_ = Task.Delay(6000).ContinueWith(t =>
{
var presence = (DynamicPoolPresence)zone.PresenceManager.CreatePresence(info.presenceID);
DynamicPoolPresence presence = (DynamicPoolPresence)zone.PresenceManager.CreatePresence(info.presenceID);
presence.DynamicPosition = CurrentPosition;
presence.LifeTime = info.presenceLifeTime;
presence.Summoner = info.ownerPlayer.Character;
Expand All @@ -279,17 +313,17 @@ public override void UseItem(Player player)
{
base.UseItem(player);

var nearestRift = Zone.Units.OfType<Rift>().Where(rift => rift != this).GetNearestUnit(CurrentPosition);
Rift nearestRift = Zone.Units.OfType<Rift>().Where(rift => rift != this).GetNearestUnit(CurrentPosition);
if (nearestRift == null)
{
throw new PerpetuumException(ErrorCodes.WTFErrorMedicalAttentionSuggested);
}

var teleport = _teleportStrategyFactories.TeleportWithinZoneFactory();
TeleportWithinZone teleport = _teleportStrategyFactories.TeleportWithinZoneFactory();
teleport.TargetPosition = nearestRift.CurrentPosition;
teleport.ApplyTeleportSickness = true;
teleport.ApplyInvulnerable = true;
teleport.DoTeleportAsync(player);
_ = teleport.DoTeleportAsync(player);

}

Expand Down
Loading