Creating PlayerMask

This commit is contained in:
teinarss
2019-07-07 19:45:48 +02:00
committed by reaperrr
parent 2ddf9fa826
commit 3a17b26405
3 changed files with 237 additions and 0 deletions

View File

@@ -33,6 +33,8 @@ namespace OpenRA
public enum WinState { Undefined, Won, Lost }
public class PlayerBitMask { }
public class Player : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding
{
struct StanceColors
@@ -71,6 +73,12 @@ namespace OpenRA
readonly bool inMissionMap;
readonly IUnlocksRenderPlayer[] unlockRenderPlayer;
// Each player is identified with a unique bit in the set
// Cache masks for the player's index and ally/enemy player indices for performance.
public LongBitSet<PlayerBitMask> PlayerMask;
public LongBitSet<PlayerBitMask> AllyMask = default(LongBitSet<PlayerBitMask>);
public LongBitSet<PlayerBitMask> EnemyMask = default(LongBitSet<PlayerBitMask>);
public bool UnlockedRenderPlayer
{
get
@@ -153,6 +161,9 @@ namespace OpenRA
DisplayFaction = ChooseDisplayFaction(world, pr.Faction);
}
if (!Spectating)
PlayerMask = new LongBitSet<PlayerBitMask>(InternalName);
var playerActorType = world.Type == WorldType.Editor ? "EditorPlayer" : "Player";
PlayerActor = world.CreateActor(playerActorType, new TypeDictionary { new OwnerInit(this) });
Shroud = PlayerActor.Trait<Shroud>();