Move PlayerExperience from Infiltrates to InfiltrateFor

This commit is contained in:
Gustas
2023-05-30 20:15:07 +03:00
committed by Matthias Mailänder
parent 3207d01cf2
commit 4cd4e1f8ea
17 changed files with 167 additions and 19 deletions

View File

@@ -64,9 +64,6 @@ namespace OpenRA.Mods.Cnc.Activities
foreach (var t in targetActor.TraitsImplementing<INotifyInfiltrated>())
t.Infiltrated(targetActor, self, infiltrates.Info.Types);
var exp = self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
exp?.GiveExperience(infiltrates.Info.PlayerExperience);
if (!string.IsNullOrEmpty(infiltrates.Info.Notification))
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
infiltrates.Info.Notification, self.Owner.Faction.InternalName);

View File

@@ -33,6 +33,12 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Maximum amount of funds which will be stolen.")]
public readonly int Maximum = int.MaxValue;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[Desc("Experience to grant to the infiltrating player based on cash stolen.")]
public readonly int PlayerExperiencePercentage = 0;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get robbed.")]
public readonly string InfiltratedNotification = null;
@@ -74,6 +80,8 @@ namespace OpenRA.Mods.Cnc.Traits
targetResources.TakeCash(toTake);
spyResources.GiveCash(toGive);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience + toTake * info.PlayerExperiencePercentage / 100);
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);

View File

@@ -24,6 +24,9 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
public override object Create(ActorInitializer init) { return new InfiltrateForDecoration(init.Self, this); }
}
@@ -43,6 +46,8 @@ namespace OpenRA.Mods.Cnc.Traits
if (!info.Types.Overlaps(types))
return;
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
infiltrators.Add(infiltrator.Owner);
}

View File

@@ -22,6 +22,9 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
@@ -62,6 +65,8 @@ namespace OpenRA.Mods.Cnc.Traits
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
var preventReset = self.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>()
.Any(p => p.PreventShroudReset(self));

View File

@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Measured in ticks.")]
public readonly int Duration = 500;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
@@ -65,6 +68,8 @@ namespace OpenRA.Mods.Cnc.Traits
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
playerPower.TriggerPowerOutage(info.Duration);
}

View File

@@ -24,6 +24,9 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when technology gets stolen.")]
public readonly string InfiltratedNotification = null;
@@ -64,6 +67,8 @@ namespace OpenRA.Mods.Cnc.Traits
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary
{
new OwnerInit(infiltrator.Owner)

View File

@@ -25,6 +25,9 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[Desc("Text notification the victim will see when they get sabotaged.")]
public readonly string InfiltratedTextNotification = null;
@@ -61,6 +64,8 @@ namespace OpenRA.Mods.Cnc.Traits
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
var manager = self.Owner.PlayerActor.Trait<SupportPowerManager>();
var powers = manager.GetPowersForActor(self).Where(sp => !sp.Disabled);
foreach (var power in powers)

View File

@@ -28,6 +28,9 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly bool SkipMakeAnims = true;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
@@ -61,6 +64,8 @@ namespace OpenRA.Mods.Cnc.Traits
if (facing != null)
transform.Facing = facing.Facing;
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
self.QueueActivity(false, transform);
}
}

View File

@@ -44,9 +44,6 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Text notification to display when a target is infiltrated.")]
public readonly string TextNotification = null;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[CursorReference]
[Desc("Cursor to display when able to infiltrate the target actor.")]
public readonly string EnterCursor = "enter";