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)
|
||||
{
|
||||
body.Docked = true;
|
||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
trait.Docked();
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||
nd.Docked(self, Refinery);
|
||||
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||
nd.Docked(Refinery, self);
|
||||
|
||||
if (spriteOverlay != null && !spriteOverlay.Visible)
|
||||
@@ -63,11 +64,11 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
body.Docked = false;
|
||||
spriteOverlay.Visible = false;
|
||||
|
||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
trait.Undocked();
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||
nd.Undocked(self, Refinery);
|
||||
|
||||
if (Refinery.IsInWorld && !Refinery.IsDead)
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||
nd.Undocked(Refinery, self);
|
||||
});
|
||||
}
|
||||
@@ -76,11 +77,11 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
dockingState = DockingState.Complete;
|
||||
body.Docked = false;
|
||||
|
||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
trait.Undocked();
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||
nd.Undocked(self, Refinery);
|
||||
|
||||
if (Refinery.IsInWorld && !Refinery.IsDead)
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||
nd.Undocked(Refinery, self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public override void OnStateDock(Actor self)
|
||||
{
|
||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
trait.Docked();
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||
nd.Docked(self, Refinery);
|
||||
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||
nd.Docked(Refinery, self);
|
||||
|
||||
if (wda != null)
|
||||
@@ -62,11 +62,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
void NotifyUndock(Actor self)
|
||||
{
|
||||
dockingState = DockingState.Complete;
|
||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
trait.Undocked();
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDockClient>())
|
||||
nd.Undocked(self, Refinery);
|
||||
|
||||
if (Refinery.IsInWorld && !Refinery.IsDead)
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDockHost>())
|
||||
nd.Undocked(Refinery, self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,5 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
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,
|
||||
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction, INotifyBeingResupplied
|
||||
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyDockClient, INotifyBeingResupplied
|
||||
{
|
||||
[Sync]
|
||||
int remainingTime;
|
||||
@@ -270,15 +270,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return color;
|
||||
}
|
||||
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
||||
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor) { }
|
||||
|
||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
||||
|
||||
void INotifyHarvesterAction.Harvested(Actor self, string resourceType) { }
|
||||
|
||||
void INotifyHarvesterAction.Docked()
|
||||
void INotifyDockClient.Docked(Actor self, Actor host)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
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;
|
||||
bool docked;
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
anim.Animation.PlayThen(Info.Sequence, PlayDockingOverlay);
|
||||
}
|
||||
|
||||
void INotifyDocking.Docked(Actor self, Actor harvester) { docked = true; PlayDockingOverlay(); }
|
||||
void INotifyDocking.Undocked(Actor self, Actor harvester) { docked = false; }
|
||||
void INotifyDockHost.Docked(Actor self, Actor client) { docked = true; PlayDockingOverlay(); }
|
||||
void INotifyDockHost.Undocked(Actor self, Actor client) { docked = false; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
wsb.PlayCustomAnimation(self, sequence);
|
||||
}
|
||||
|
||||
void INotifyHarvesterAction.Docked() { }
|
||||
void INotifyHarvesterAction.Undocked() { }
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor refineryActor) { }
|
||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
||||
|
||||
@@ -66,8 +66,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
void INotifyHarvesterAction.MovingToResources(Actor self, CPos targetCell) { }
|
||||
void INotifyHarvesterAction.MovingToRefinery(Actor self, Actor targetRefinery) { }
|
||||
void INotifyHarvesterAction.MovementCancelled(Actor self) { }
|
||||
void INotifyHarvesterAction.Docked() { }
|
||||
void INotifyHarvesterAction.Undocked() { }
|
||||
|
||||
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 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 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]
|
||||
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 MovementCancelled(Actor self);
|
||||
void Harvested(Actor self, string resourceType);
|
||||
void Docked();
|
||||
void Undocked();
|
||||
}
|
||||
|
||||
[RequireExplicitImplementation]
|
||||
|
||||
Reference in New Issue
Block a user