Add INotifyDockHost and INotifyDockClient interfaces
Rename INotifyDocking to INotifyDockHost and extract INotifyDockClient from INotifyHarvesterAction
This commit is contained in:
@@ -30,9 +30,10 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
public override void OnStateDock(Actor self)
|
public override void OnStateDock(Actor self)
|
||||||
{
|
{
|
||||||
body.Docked = true;
|
body.Docked = true;
|
||||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||||
trait.Docked();
|
nd.Docked(self, Refinery);
|
||||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
|
||||||
|
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||||
nd.Docked(Refinery, self);
|
nd.Docked(Refinery, self);
|
||||||
|
|
||||||
if (spriteOverlay != null && !spriteOverlay.Visible)
|
if (spriteOverlay != null && !spriteOverlay.Visible)
|
||||||
@@ -63,11 +64,11 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
body.Docked = false;
|
body.Docked = false;
|
||||||
spriteOverlay.Visible = false;
|
spriteOverlay.Visible = false;
|
||||||
|
|
||||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||||
trait.Undocked();
|
nd.Undocked(self, Refinery);
|
||||||
|
|
||||||
if (Refinery.IsInWorld && !Refinery.IsDead)
|
if (Refinery.IsInWorld && !Refinery.IsDead)
|
||||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||||
nd.Undocked(Refinery, self);
|
nd.Undocked(Refinery, self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -76,11 +77,11 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
dockingState = DockingState.Complete;
|
dockingState = DockingState.Complete;
|
||||||
body.Docked = false;
|
body.Docked = false;
|
||||||
|
|
||||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||||
trait.Undocked();
|
nd.Undocked(self, Refinery);
|
||||||
|
|
||||||
if (Refinery.IsInWorld && !Refinery.IsDead)
|
if (Refinery.IsInWorld && !Refinery.IsDead)
|
||||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||||
nd.Undocked(Refinery, self);
|
nd.Undocked(Refinery, self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override void OnStateDock(Actor self)
|
public override void OnStateDock(Actor self)
|
||||||
{
|
{
|
||||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||||
trait.Docked();
|
nd.Docked(self, Refinery);
|
||||||
|
|
||||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||||
nd.Docked(Refinery, self);
|
nd.Docked(Refinery, self);
|
||||||
|
|
||||||
if (wda != null)
|
if (wda != null)
|
||||||
@@ -62,11 +62,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
void NotifyUndock(Actor self)
|
void NotifyUndock(Actor self)
|
||||||
{
|
{
|
||||||
dockingState = DockingState.Complete;
|
dockingState = DockingState.Complete;
|
||||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||||
trait.Undocked();
|
nd.Undocked(self, Refinery);
|
||||||
|
|
||||||
if (Refinery.IsInWorld && !Refinery.IsDead)
|
if (Refinery.IsInWorld && !Refinery.IsDead)
|
||||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||||
nd.Undocked(Refinery, self);
|
nd.Undocked(Refinery, self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,5 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
void INotifyHarvesterAction.Harvested(Actor self, string resourceType) { }
|
void INotifyHarvesterAction.Harvested(Actor self, string resourceType) { }
|
||||||
void INotifyHarvesterAction.Docked() { }
|
|
||||||
void INotifyHarvesterAction.Undocked() { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Cloak : PausableConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration,
|
public class Cloak : PausableConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration,
|
||||||
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction, INotifyBeingResupplied
|
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyDockClient, INotifyBeingResupplied
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
int remainingTime;
|
int remainingTime;
|
||||||
@@ -270,15 +270,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
void INotifyDockClient.Docked(Actor self, Actor host)
|
||||||
|
|
||||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor) { }
|
|
||||||
|
|
||||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
|
||||||
|
|
||||||
void INotifyHarvesterAction.Harvested(Actor self, string resourceType) { }
|
|
||||||
|
|
||||||
void INotifyHarvesterAction.Docked()
|
|
||||||
{
|
{
|
||||||
if (Info.UncloakOn.HasFlag(UncloakType.Dock))
|
if (Info.UncloakOn.HasFlag(UncloakType.Dock))
|
||||||
{
|
{
|
||||||
@@ -287,7 +279,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyHarvesterAction.Undocked()
|
void INotifyDockClient.Undocked(Actor self, Actor host)
|
||||||
{
|
{
|
||||||
isDocking = false;
|
isDocking = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
public override object Create(ActorInitializer init) { return new WithDockedOverlay(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new WithDockedOverlay(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithDockedOverlay : PausableConditionalTrait<WithDockedOverlayInfo>, INotifyDocking
|
public class WithDockedOverlay : PausableConditionalTrait<WithDockedOverlayInfo>, INotifyDockHost
|
||||||
{
|
{
|
||||||
readonly AnimationWithOffset anim;
|
readonly AnimationWithOffset anim;
|
||||||
bool docked;
|
bool docked;
|
||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
anim.Animation.PlayThen(Info.Sequence, PlayDockingOverlay);
|
anim.Animation.PlayThen(Info.Sequence, PlayDockingOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyDocking.Docked(Actor self, Actor harvester) { docked = true; PlayDockingOverlay(); }
|
void INotifyDockHost.Docked(Actor self, Actor client) { docked = true; PlayDockingOverlay(); }
|
||||||
void INotifyDocking.Undocked(Actor self, Actor harvester) { docked = false; }
|
void INotifyDockHost.Undocked(Actor self, Actor client) { docked = false; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
wsb.PlayCustomAnimation(self, sequence);
|
wsb.PlayCustomAnimation(self, sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyHarvesterAction.Docked() { }
|
|
||||||
void INotifyHarvesterAction.Undocked() { }
|
|
||||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
||||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor) { }
|
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor) { }
|
||||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
||||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor targetRefinery) { }
|
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor targetRefinery) { }
|
||||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
||||||
void INotifyHarvesterAction.Docked() { }
|
|
||||||
void INotifyHarvesterAction.Undocked() { }
|
|
||||||
|
|
||||||
public static int ZOffsetFromCenter(Actor self, WPos pos, int offset)
|
public static int ZOffsetFromCenter(Actor self, WPos pos, int offset)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,7 +162,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
||||||
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced, string productionType, TypeDictionary init); }
|
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced, string productionType, TypeDictionary init); }
|
||||||
public interface INotifyDelivery { void IncomingDelivery(Actor self); void Delivered(Actor self); }
|
public interface INotifyDelivery { void IncomingDelivery(Actor self); void Delivered(Actor self); }
|
||||||
public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); }
|
|
||||||
|
[RequireExplicitImplementation]
|
||||||
|
public interface INotifyDockHost { void Docked(Actor self, Actor client); void Undocked(Actor self, Actor client); }
|
||||||
|
[RequireExplicitImplementation]
|
||||||
|
public interface INotifyDockClient { void Docked(Actor self, Actor host); void Undocked(Actor self, Actor host); }
|
||||||
|
|
||||||
[RequireExplicitImplementation]
|
[RequireExplicitImplementation]
|
||||||
public interface INotifyResourceAccepted { void OnResourceAccepted(Actor self, Actor refinery, string resourceType, int count, int value); }
|
public interface INotifyResourceAccepted { void OnResourceAccepted(Actor self, Actor refinery, string resourceType, int count, int value); }
|
||||||
@@ -202,8 +206,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
void MovingToRefinery(Actor self, Actor refineryActor);
|
void MovingToRefinery(Actor self, Actor refineryActor);
|
||||||
void MovementCancelled(Actor self);
|
void MovementCancelled(Actor self);
|
||||||
void Harvested(Actor self, string resourceType);
|
void Harvested(Actor self, string resourceType);
|
||||||
void Docked();
|
|
||||||
void Undocked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequireExplicitImplementation]
|
[RequireExplicitImplementation]
|
||||||
|
|||||||
Reference in New Issue
Block a user