Skip to content

Commit ad0368a

Browse files
authored
fix: actually take DirectionFix into account (AscensionGameDev#2022)
1 parent b6b1144 commit ad0368a

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

Intersect.Server.Core/Entities/Entity.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,8 +1155,15 @@ public virtual void Move(Direction moveDir, Player forPlayer, bool doNotUpdate =
11551155
}
11561156
}
11571157

1158+
protected virtual bool CanLookInDirection(Direction direction) => true;
1159+
11581160
public void ChangeDir(Direction dir)
11591161
{
1162+
if (!CanLookInDirection(dir))
1163+
{
1164+
return;
1165+
}
1166+
11601167
if (dir == Direction.None || Dir == dir)
11611168
{
11621169
return;

Intersect.Server.Core/Entities/Events/EventPageInstance.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -824,17 +824,31 @@ out EntityType entityType
824824
return base.CanMoveInDirection(direction, out blockerType, out entityType);
825825
}
826826

827+
protected override bool CanLookInDirection(Direction direction)
828+
{
829+
return !mDirectionFix && base.CanLookInDirection(direction);
830+
}
831+
827832
public void TurnTowardsPlayer()
828833
{
829-
Direction lookDir;
830-
if (Player != null && GlobalClone == null) //Local Event
834+
if (mDirectionFix)
831835
{
832-
lookDir = GetDirectionTo(Player);
833-
if (lookDir > Direction.None)
834-
{
835-
ChangeDir(lookDir);
836-
}
836+
return;
837837
}
838+
839+
// Local Event
840+
if (Player == null || GlobalClone != null)
841+
{
842+
return;
843+
}
844+
845+
var lookDir = GetDirectionTo(Player);
846+
if (!Enum.IsDefined(lookDir) || lookDir == Direction.None)
847+
{
848+
return;
849+
}
850+
851+
ChangeDir(lookDir);
838852
}
839853

840854
public bool ShouldDespawn(MapController map)

0 commit comments

Comments
 (0)