Skip to content

Commit

Permalink
WIP: unloading crate to Refinery (using DockHost)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldgg2 committed Jun 23, 2024
1 parent 51a3c65 commit 68eb281
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
11 changes: 9 additions & 2 deletions OpenRA.Mods.OpenE2140/Traits/Resources/CrateTransporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ public override bool CanDockAt(Actor hostActor, IDockHost host, bool forceEnter
if (!base.CanDockAt(hostActor, host, forceEnter, ignoreOccupancy))
return false;

if (host is ResourceMine resourceMine)
if (host is ResourceMine)
return this.crate == null;
else
else if (host is ResourceRefinery)
return this.crate != null;

return false;
}

public override bool OnDockTick(Actor self, Actor hostActor, IDockHost host)
Expand All @@ -87,6 +89,11 @@ public override bool OnDockTick(Actor self, Actor hostActor, IDockHost host)
{
this.crate = resourceMine.RemoveCrate(hostActor);
}
else if (host is ResourceRefinery resourceRefinery && this.crate != null)
{
resourceRefinery.Activate(hostActor, this.crate);
this.crate = null;
}

return true;
}
Expand Down
17 changes: 1 addition & 16 deletions OpenRA.Mods.OpenE2140/Traits/Resources/ResourceRefinery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,6 @@ protected override void TickInner(Actor self)
//if (this.IsTraitDisabled || this.IsTraitPaused)
if (this.IsTraitDisabled)
return;

if (this.crate != null || self.World.WorldTick % 100 != 0)
return;

this.Activate(
self,
self.World.CreateActor(
false,
"crate",
new TypeDictionary { new ParentActorInit(self), new LocationInit(self.Location), new OwnerInit(self.Owner) }
)
.Trait<ResourceCrate>()
);

if (this.crate != null)
this.crate.Resources = 500;
}

protected override void Complete(Actor self)
Expand All @@ -80,6 +64,7 @@ protected override void Complete(Actor self)
return;

this.playerResources?.GiveCash(this.crate.Resources);
this.crate.Actor.Dispose();
this.crate = null;
}

Expand Down
12 changes: 10 additions & 2 deletions mods/e2140/content/shared/buildings/refinery/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ shared_buildings_refinery:
ZOffset: 1336
RequiresCondition: !Transforming
PauseOnCondition: !Powered
# DockHost
Type: Unload
DockOffset: 1024,1024,0
DockAngle: 512
DockWait: 1
IsDragRequired: true
DragOffset: 1404,130,0
DragLength: 20
WithIdleOverlay@Powered:
Sequence: idle-lights
RequiresCondition: Powered
Expand Down Expand Up @@ -66,7 +74,7 @@ shared_buildings_refinery:
Offset: -512,112,0
Image: refinery_smoke
Sequences: chimney_smoke
RequiresCondition: !Transforming && Powered && !damaged
RequiresCondition: !Transforming && Powered && !damaged && BeltActive
FloatingSpriteEmitter@Damaged:
Duration: -1
Lifetime: 27
Expand All @@ -78,7 +86,7 @@ shared_buildings_refinery:
Offset: -512,812,0
Image: refinery_smoke
Sequences: chimney_smoke
RequiresCondition: !Transforming && Powered && damaged
RequiresCondition: !Transforming && Powered && damaged && BeltActive
Encyclopedia:
Category: Shared - Buildings
Order: 3
Expand Down

0 comments on commit 68eb281

Please sign in to comment.