Skip to content

Commit

Permalink
Add Resource Interface so client plugins can figure out the base reso…
Browse files Browse the repository at this point in the history
…urce (#934)

* Add Resource Interface so client plugins can figure out the base resource

* Expose IsDead as IsDepleted for resources, remove setter from BaseResource on IResource
  • Loading branch information
Cheshire92 committed Oct 9, 2021
1 parent 6c25384 commit d39d457
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
12 changes: 12 additions & 0 deletions Intersect.Client.Framework/Entities/IResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Intersect.GameObjects;

namespace Intersect.Client.Framework.Entities
{
public interface IResource : IEntity
{
ResourceBase BaseResource { get; }

bool IsDepleted { get; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<Compile Include="Entities\IHotbarInstance.cs" />
<Compile Include="Entities\IPartyMember.cs" />
<Compile Include="Entities\IPlayer.cs" />
<Compile Include="Entities\IResource.cs" />
<Compile Include="Entities\IStatus.cs" />
<Compile Include="Entities\Label.cs" />
<Compile Include="Entities\LabelType.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Client/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ public void LoadAnimationTextures(string tex)
{
if (en.Value.GetType() == typeof(Resource))
{
var resourceBase = ((Resource)en.Value).GetResourceBase();
var resourceBase = ((Resource)en.Value).BaseResource;
if (resourceBase != null)
{
if (!ignoreAliveResources && !((Resource)en.Value).IsDead)
Expand Down
13 changes: 5 additions & 8 deletions Intersect.Client/Entities/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
namespace Intersect.Client.Entities
{

public partial class Resource : Entity
public partial class Resource : Entity, IResource
{

private bool _waitingForTilesets;

public ResourceBase BaseResource;
public ResourceBase BaseResource { get; set; }

public bool IsDead;
bool IResource.IsDepleted => IsDead;

public bool IsDead { get; set; }

FloatRect mDestRectangle = FloatRect.Empty;

Expand Down Expand Up @@ -67,11 +69,6 @@ public override string Sprite
}
}

public ResourceBase GetResourceBase()
{
return BaseResource;
}

public override void Load(EntityPacket packet)
{
base.Load(packet);
Expand Down

0 comments on commit d39d457

Please sign in to comment.