Skip to content

Commit

Permalink
Add option for map animations to be considered blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsnider committed Oct 2, 2020
1 parent 58ce0cc commit 2609352
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Intersect (Core)/GameObjects/Maps/MapAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,13 @@ public class MapAnimationAttribute : MapAttribute

public Guid AnimationId { get; set; }

public bool IsBlock { get; set; }

public override MapAttribute Clone()
{
var att = (MapAnimationAttribute) base.Clone();
att.AnimationId = AnimationId;
att.IsBlock = IsBlock;

return att;
}
Expand Down
3 changes: 2 additions & 1 deletion Intersect.Client/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,8 @@ public int IsTileBlocked(
{
if (gameMap.Attributes[tmpX, tmpY] != null)
{
if (gameMap.Attributes[tmpX, tmpY].Type == MapAttributes.Blocked)
if (gameMap.Attributes[tmpX, tmpY].Type == MapAttributes.Blocked ||
(gameMap.Attributes[tmpX, tmpY].Type == MapAttributes.Animation && ((MapAnimationAttribute)gameMap.Attributes[tmpX, tmpY]).IsBlock))
{
return -2;
}
Expand Down
14 changes: 13 additions & 1 deletion Intersect.Editor/Forms/DockingElements/frmMapLayers.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Intersect.Editor/Forms/DockingElements/frmMapLayers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public MapAttribute CreateAttribute()
case MapAttributes.Animation:
var animationAttribute = attribute as MapAnimationAttribute;
animationAttribute.AnimationId = AnimationBase.IdFromList(cmbAnimationAttribute.SelectedIndex);
animationAttribute.IsBlock = chkAnimationBlock.Checked;
break;

case MapAttributes.Slide:
Expand Down Expand Up @@ -896,6 +897,7 @@ private void InitLocalization()
//Map Animation Groupbox
grpAnimation.Text = Strings.Attributes.mapanimation;
lblAnimation.Text = Strings.Attributes.mapanimation;
chkAnimationBlock.Text = Strings.Attributes.mapanimationblock;

//Slide Groupbox
grpSlide.Text = Strings.Attributes.slide;
Expand Down
2 changes: 2 additions & 0 deletions Intersect.Editor/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ public struct Attributes

public static LocalizedString mapanimation = @"Animation";

public static LocalizedString mapanimationblock = @"Block Tile";

public static LocalizedString mapsound = @"Map Sound";

public static LocalizedString npcavoid = @"NPC Avoid";
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public virtual int CanMove(int moveDir)
var tileAttribute = MapInstance.Get(tile.GetMapId()).Attributes[tile.GetX(), tile.GetY()];
if (tileAttribute != null)
{
if (tileAttribute.Type == MapAttributes.Blocked)
if (tileAttribute.Type == MapAttributes.Blocked || (tileAttribute.Type == MapAttributes.Animation && ((MapAnimationAttribute)tileAttribute).IsBlock))
{
return -2;
}
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server/Entities/Projectile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public bool CheckForCollision(ProjectileSpawn spawn)
}

if (attribute != null &&
attribute.Type == MapAttributes.Blocked &&
(attribute.Type == MapAttributes.Blocked || attribute.Type == MapAttributes.Animation && ((MapAnimationAttribute)attribute).IsBlock) &&
!spawn.ProjectileBase.IgnoreMapBlocks)
{
killSpawn = true;
Expand Down
6 changes: 4 additions & 2 deletions Intersect.Server/Maps/MapInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ private void CacheMapBlocks()
if (Attributes[x, y] != null)
{
if (Attributes[x, y].Type == MapAttributes.Blocked ||
Attributes[x, y].Type == MapAttributes.GrappleStone)
Attributes[x, y].Type == MapAttributes.GrappleStone ||
Attributes[x,y].Type == MapAttributes.Animation && ((MapAnimationAttribute)Attributes[x,y]).IsBlock)
{
blocks.Add(new BytePoint(x, y));
npcBlocks.Add(new BytePoint(x, y));
Expand Down Expand Up @@ -1107,7 +1108,8 @@ public void ClearConnections(int side = -1)
public bool TileBlocked(int x, int y)
{
//Check if tile is a blocked attribute
if (Attributes[x, y] != null && Attributes[x, y].Type == MapAttributes.Blocked)
if (Attributes[x, y] != null && (Attributes[x, y].Type == MapAttributes.Blocked ||
Attributes[x,y].Type == MapAttributes.Animation && ((MapAnimationAttribute)Attributes[x,y]).IsBlock))
{
return true;
}
Expand Down

0 comments on commit 2609352

Please sign in to comment.