Skip to content

Commit

Permalink
Finish rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Jul 31, 2018
1 parent 6153d74 commit e9d1983
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 53 deletions.
14 changes: 0 additions & 14 deletions OpenRA.Game/Graphics/RgbaColorRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,6 @@ public void FillTriangle(float3 a, float3 b, float3 c, Color color)
parent.DrawRGBAVertices(vertices);
}

public void FillTriangle(float3 a, float3 b, float3 c, Color color)
{
color = Util.PremultiplyAlpha(color);
var cr = color.R / 255.0f;
var cg = color.G / 255.0f;
var cb = color.B / 255.0f;
var ca = color.A / 255.0f;

vertices[0] = new Vertex(a + Offset, cr, cg, cb, ca, 0, 0);
vertices[1] = new Vertex(b + Offset, cr, cg, cb, ca, 0, 0);
vertices[2] = new Vertex(c + Offset, cr, cg, cb, ca, 0, 0);
parent.DrawRGBAVertices(vertices);
}

public void FillRect(float3 tl, float3 br, Color color)
{
var tr = new float3(br.X, tl.Y, tl.Z);
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Graphics/WorldRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void Draw()

if (debugVis.Value != null && lastDepthPreviewEnabled != debugVis.Value.DepthBuffer)
{
lastDepthPreviewEnabled = debugVis.Value.ShowDepthPreview;
lastDepthPreviewEnabled = debugVis.Value.DepthBuffer;
Game.Renderer.WorldSpriteRenderer.SetDepthPreviewEnabled(lastDepthPreviewEnabled);
}

Expand Down
2 changes: 0 additions & 2 deletions OpenRA.Mods.Common/Traits/Mobile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,6 @@ public void ResolveOrder(Actor self, Order order)
if (!order.Queued)
self.CancelActivity();

TicksBeforePathing = AverageTicksBeforePathing + self.World.SharedRandom.Next(-SpreadTicksBeforePathing, SpreadTicksBeforePathing);

self.SetTargetLine(Target.FromCell(self.World, loc), Color.Green);
self.QueueActivity(order.Queued, new Move(self, loc, WDist.FromCells(8), null, true));
}
Expand Down
10 changes: 2 additions & 8 deletions OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,10 @@ public void ResolveOrder(Actor self, Order order)
break;

var actor = order.Target.Actor;
var health = actor.TraitOrDefault<Health>();
var args = order.TargetString.Split(' ');
var damageTypes = new HashSet<string>();

foreach (var damageType in args)
damageTypes.Add(damageType);

if (health != null)
health.InflictDamage(actor, actor, new Damage(health.HP, damageTypes), true);
var damageTypes = BitSet<DamageType>.FromStringsNoAlloc(args);

actor.Kill(actor, damageTypes);
break;
}

Expand Down
28 changes: 18 additions & 10 deletions OpenRA.Mods.Common/Traits/SharedPassenger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ bool CanEnter(Actor target)

public string VoicePhraseForOrder(Actor self, Order order)
{
if (order.OrderString != "EnterSharedTransport" || !CanEnter(order.TargetActor))
if (order.OrderString != "EnterSharedTransport")
return null;

return Info.Voice;
Expand Down Expand Up @@ -137,18 +137,26 @@ void INotifyExitedSharedCargo.OnExitedSharedCargo(Actor self, Actor cargo)

public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "EnterSharedTransport")
{
if (order.TargetActor == null) return;
if (!CanEnter(order.TargetActor)) return;
if (!IsCorrectCargoType(order.TargetActor)) return;
if (order.OrderString != "EnterSharedTransport")
return;

// Enter orders are only valid for own/allied actors,
// which are guaranteed to never be frozen.
if (order.Target.Type != TargetType.Actor)
return;

var target = Target.FromOrder(self.World, order);
self.SetTargetLine(target, Color.Green);
var targetActor = order.Target.Actor;
if (!CanEnter(targetActor))
return;

if (!IsCorrectCargoType(targetActor))
return;

if (!order.Queued)
self.CancelActivity();
self.QueueActivity(new EnterSharedTransport(self, order.TargetActor));
}

self.SetTargetLine(order.Target, Color.Green);
self.QueueActivity(new EnterSharedTransport(self, targetActor));
}

public bool Reserve(Actor self, SharedCargo cargo)
Expand Down
3 changes: 2 additions & 1 deletion OpenRA.Mods.Gen/Traits/DamagedByRadioactivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;

/* Works without base engine modification */
Expand All @@ -34,7 +35,7 @@ class DamagedByRadioactivityInfo : ConditionalTraitInfo, Requires<HealthInfo>
public readonly int DamageInterval = 16;

[Desc("Apply the damage using these damagetypes.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>();
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);

[Desc("Receive damage from the radioactivity layer with this name.")]
public readonly string RadioactivityLayerName = "radioactivity";
Expand Down
3 changes: 2 additions & 1 deletion OpenRA.Mods.Gen/Traits/DelayedWeaponAttachable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Drawing;
using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;

namespace OpenRA.Mods.Yupgi_alert.Traits
Expand Down Expand Up @@ -82,7 +83,7 @@ void INotifyKilled.Killed(Actor self, AttackInfo e)
{
foreach (var trigger in Container)
{
if (trigger.DeathTypes.Count > 0 && !e.Damage.DamageTypes.Overlaps(trigger.DeathTypes))
if (!trigger.DeathTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(trigger.DeathTypes))
continue;

trigger.Activate(self);
Expand Down
3 changes: 2 additions & 1 deletion OpenRA.Mods.Gen/Traits/DelayedWeaponTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.Yupgi_alert.Warheads;
using OpenRA.Primitives;
using OpenRA.Traits;

namespace OpenRA.Mods.Yupgi_alert.Traits
{
public class DelayedWeaponTrigger
{
public readonly HashSet<string> DeathTypes;
public readonly BitSet<DamageType> DeathTypes;

public readonly int TriggerTime;

Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Gen/Traits/Nydus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static bool HasEnoughCanals(Actor self)
static bool IsValidOrder(Actor self, Order order)
{
// Not targeting a frozen actor
if (order.ExtraData == 0 && order.TargetActor == null)
if (order.ExtraData == 0 && order.Target.Actor == null)
return false;

// The owner must own at least two nydus canals.
Expand All @@ -170,7 +170,7 @@ static bool IsValidOrder(Actor self, Order order)

// primary buildings are where entered units exit.
// You don't want to put them in the primary building.
return !order.TargetActor.IsPrimaryNydusExit();
return !order.Target.Actor.IsPrimaryNydusExit();
}

public string VoicePhraseForOrder(Actor self, Order order)
Expand Down
6 changes: 6 additions & 0 deletions OpenRA.Mods.Gen/Traits/Player/BotProvidesPrerequisite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public class BotProvidesPrerequisiteInfo : ITechTreePrerequisiteInfo
// Don't set this to false, even though you can.
[Desc("Should it recheck everything when it is captured?")]
public readonly bool ResetOnOwnerChange = true;

IEnumerable<string> ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info)
{
return new string[] { Prerequisite ?? info.Name };
}

public object Create(ActorInitializer init) { return new BotProvidesPrerequisite(init, this); }
}

Expand Down
5 changes: 3 additions & 2 deletions OpenRA.Mods.Gen/Traits/SpawnedExplodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;

/* Works without base engine modification. */
Expand All @@ -41,7 +42,7 @@ public class SpawnedExplodesInfo : ConditionalTraitInfo, IRulesetLoaded, Require
public readonly int DamageThreshold = 0;

[Desc("DeathType(s) that trigger the explosion. Leave empty to always trigger an explosion.")]
public readonly HashSet<string> DeathTypes = new HashSet<string>();
public readonly BitSet<DamageType> DeathTypes = default(BitSet<DamageType>);

[Desc("Possible values are CenterPosition (explosion at the actors' center) and ",
"Footprint (explosion on each occupied cell).")]
Expand Down Expand Up @@ -84,7 +85,7 @@ void INotifyKilled.Killed(Actor self, AttackInfo e)
if (self.World.SharedRandom.Next(100) > Info.Chance)
return;

if (Info.DeathTypes.Count > 0 && !e.Damage.DamageTypes.Overlaps(Info.DeathTypes))
if (!Info.DeathTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(Info.DeathTypes))
return;

var weapon = ChooseWeaponForExplosion(self);
Expand Down
25 changes: 15 additions & 10 deletions OpenRA.Mods.Gen/Traits/Supply/SupplyCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,29 @@ string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
}

public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Collect")
{
// TODO: Add support for FrozenActors
if (order.Target.Type != TargetType.Actor)
return;

var targetActor = order.Target.Actor;
if (order.OrderString == "Collect")
{
var dock = order.TargetActor.TraitOrDefault<SupplyDock>();
var dock = targetActor.TraitOrDefault<SupplyDock>();
if (dock == null || !Info.SupplyTypes.Overlaps(dock.Info.SupplyTypes))
return;

if (IsFull)
return;

if (order.TargetActor != collectionBuilding)
collectionBuilding = order.TargetActor;
if (targetActor != collectionBuilding)
collectionBuilding = targetActor;

idleSmart = true;
Waiting = false;
DeliveryAnimPlayed = false;

self.SetTargetLine(Target.FromOrder(self.World, order), Color.Green);
self.SetTargetLine(order.Target, Color.Green);

self.CancelActivity();

Expand All @@ -208,21 +213,21 @@ public void ResolveOrder(Actor self, Order order)
}
else if (order.OrderString == "Deliver")
{
var center = order.TargetActor.TraitOrDefault<SupplyCenter>();
var center = targetActor.TraitOrDefault<SupplyCenter>();
if (center == null || !Info.SupplyTypes.Overlaps(center.Info.SupplyTypes))
return;

if (IsEmpty)
return;

if (order.TargetActor != deliveryBuilding)
deliveryBuilding = order.TargetActor;
if (targetActor != deliveryBuilding)
deliveryBuilding = targetActor;

idleSmart = true;
Waiting = false;
DeliveryAnimPlayed = false;

self.SetTargetLine(Target.FromOrder(self.World, order), Color.Green);
self.SetTargetLine(order.Target, Color.Green);

self.CancelActivity();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.Yupgi_alert.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;

namespace OpenRA.Mods.Yupgi_alert.Warheads
Expand All @@ -33,7 +34,7 @@ public class AttachDelayedWeaponWarhead : WarheadAS, IRulesetLoaded<WeaponInfo>
public readonly int TriggerTime = 30;

[Desc("DeathType(s) that trigger the DelayedWeapon to activate. Leave empty to always trigger the DelayedWeapon on death.")]
public readonly HashSet<string> DeathTypes = new HashSet<string>();
public readonly BitSet<DamageType> DeathTypes = default(BitSet<DamageType>);

public WeaponInfo WeaponInfo;

Expand Down

0 comments on commit e9d1983

Please sign in to comment.