Move more files
Move VoxelNormalsPalette to TS
This commit is contained in:
98
OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs
Normal file
98
OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Limits the zone where buildings can be constructed to a radius around this actor.")]
|
||||
public class BaseProviderInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Range = 10;
|
||||
public readonly int Cooldown = 0;
|
||||
public readonly int InitialDelay = 0;
|
||||
|
||||
public object Create(ActorInitializer init) { return new BaseProvider(init.self, this); }
|
||||
}
|
||||
|
||||
public class BaseProvider : ITick, IPostRenderSelection, ISelectionBar
|
||||
{
|
||||
public readonly BaseProviderInfo Info;
|
||||
DeveloperMode devMode;
|
||||
Actor self;
|
||||
int total;
|
||||
int progress;
|
||||
|
||||
public BaseProvider(Actor self, BaseProviderInfo info)
|
||||
{
|
||||
Info = info;
|
||||
this.self = self;
|
||||
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
|
||||
progress = total = info.InitialDelay;
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (progress > 0)
|
||||
progress--;
|
||||
}
|
||||
|
||||
public void BeginCooldown()
|
||||
{
|
||||
progress = total = Info.Cooldown;
|
||||
}
|
||||
|
||||
public bool Ready()
|
||||
{
|
||||
return devMode.FastBuild || progress == 0;
|
||||
}
|
||||
|
||||
bool ValidRenderPlayer()
|
||||
{
|
||||
var allyBuildRadius = self.World.LobbyInfo.GlobalSettings.AllyBuildRadius;
|
||||
return self.Owner == self.World.RenderPlayer || (allyBuildRadius && self.Owner.IsAlliedWith(self.World.RenderPlayer));
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
// Visible to player and allies
|
||||
if (!ValidRenderPlayer())
|
||||
yield break;
|
||||
|
||||
yield return new RangeCircleRenderable(
|
||||
self.CenterPosition,
|
||||
WRange.FromCells(Info.Range),
|
||||
0,
|
||||
Color.FromArgb(128, Ready() ? Color.White : Color.Red),
|
||||
Color.FromArgb(96, Color.Black)
|
||||
);
|
||||
}
|
||||
|
||||
// Selection bar
|
||||
public float GetValue()
|
||||
{
|
||||
// Visible to player and allies
|
||||
if (!ValidRenderPlayer())
|
||||
return 0f;
|
||||
|
||||
// Ready or delay disabled
|
||||
if (progress == 0 || total == 0 || devMode.FastBuild)
|
||||
return 0f;
|
||||
|
||||
return (float)progress / total;
|
||||
}
|
||||
|
||||
public Color GetColor() { return Color.Purple; }
|
||||
}
|
||||
}
|
||||
132
OpenRA.Mods.Common/Traits/Husk.cs
Normal file
132
OpenRA.Mods.Common/Traits/Husk.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Spawns remains of a husk actor with the correct facing.")]
|
||||
public class HuskInfo : IOccupySpaceInfo, IFacingInfo
|
||||
{
|
||||
public readonly string[] AllowedTerrain = { };
|
||||
|
||||
public object Create(ActorInitializer init) { return new Husk(init, this); }
|
||||
|
||||
public int GetInitialFacing() { return 128; }
|
||||
}
|
||||
|
||||
public class Husk : IPositionable, IFacing, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDisable
|
||||
{
|
||||
readonly HuskInfo info;
|
||||
readonly Actor self;
|
||||
|
||||
readonly int dragSpeed;
|
||||
readonly WPos finalPosition;
|
||||
|
||||
[Sync] public CPos TopLeft { get; private set; }
|
||||
[Sync] public WPos CenterPosition { get; private set; }
|
||||
[Sync] public int Facing { get; set; }
|
||||
|
||||
public int ROT { get { return 0; } }
|
||||
|
||||
public Husk(ActorInitializer init, HuskInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
this.self = init.self;
|
||||
|
||||
TopLeft = init.Get<LocationInit, CPos>();
|
||||
CenterPosition = init.Contains<CenterPositionInit>() ? init.Get<CenterPositionInit, WPos>() : init.world.Map.CenterOfCell(TopLeft);
|
||||
Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : 128;
|
||||
|
||||
dragSpeed = init.Contains<HuskSpeedInit>() ? init.Get<HuskSpeedInit, int>() : 0;
|
||||
finalPosition = init.world.Map.CenterOfCell(TopLeft);
|
||||
}
|
||||
|
||||
public void Created(Actor self)
|
||||
{
|
||||
var distance = (finalPosition - CenterPosition).Length;
|
||||
if (dragSpeed > 0 && distance > 0)
|
||||
self.QueueActivity(new Drag(self, CenterPosition, finalPosition, distance / dragSpeed));
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(TopLeft, SubCell.FullCell); }
|
||||
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return false; }
|
||||
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
|
||||
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
{
|
||||
if (!self.World.Map.Contains(cell))
|
||||
return SubCell.Invalid;
|
||||
|
||||
if (!info.AllowedTerrain.Contains(self.World.Map.GetTerrainInfo(cell).Type))
|
||||
return SubCell.Invalid;
|
||||
|
||||
if (!checkTransientActors)
|
||||
return SubCell.FullCell;
|
||||
|
||||
return !self.World.ActorMap.GetUnitsAt(cell)
|
||||
.Where(x => x != ignoreActor)
|
||||
.Any() ? SubCell.FullCell : SubCell.Invalid;
|
||||
}
|
||||
|
||||
public bool CanEnterCell(CPos a, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||
{
|
||||
return GetAvailableSubCell(a, SubCell.Any, ignoreActor, checkTransientActors) != SubCell.Invalid;
|
||||
}
|
||||
|
||||
public void SetPosition(Actor self, CPos cell, SubCell subCell = SubCell.Any) { SetPosition(self, self.World.Map.CenterOfCell(cell)); }
|
||||
|
||||
public void SetVisualPosition(Actor self, WPos pos)
|
||||
{
|
||||
CenterPosition = pos;
|
||||
self.World.ScreenMap.Update(self);
|
||||
}
|
||||
|
||||
public void SetPosition(Actor self, WPos pos)
|
||||
{
|
||||
self.World.ActorMap.RemoveInfluence(self, this);
|
||||
CenterPosition = pos;
|
||||
TopLeft = self.World.Map.CellContaining(pos);
|
||||
self.World.ActorMap.AddInfluence(self, this);
|
||||
self.World.ActorMap.UpdatePosition(self, this);
|
||||
self.World.ScreenMap.Update(self);
|
||||
}
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
{
|
||||
self.World.ActorMap.AddInfluence(self, this);
|
||||
self.World.ActorMap.AddPosition(self, this);
|
||||
self.World.ScreenMap.Add(self);
|
||||
}
|
||||
|
||||
public void RemovedFromWorld(Actor self)
|
||||
{
|
||||
self.World.ActorMap.RemoveInfluence(self, this);
|
||||
self.World.ActorMap.RemovePosition(self, this);
|
||||
self.World.ScreenMap.Remove(self);
|
||||
}
|
||||
|
||||
public bool Disabled
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
public class HuskSpeedInit : IActorInit<int>
|
||||
{
|
||||
[FieldFromYamlKey] readonly int value = 0;
|
||||
public HuskSpeedInit() { }
|
||||
public HuskSpeedInit(int init) { value = init; }
|
||||
public int Value(World world) { return value; }
|
||||
}
|
||||
}
|
||||
36
OpenRA.Mods.Common/Traits/Player/ActorGroupProxy.cs
Normal file
36
OpenRA.Mods.Common/Traits/Player/ActorGroupProxy.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Part of the unfinished group-movement system. Attach this to the player actor.")]
|
||||
class ActorGroupProxyInfo : TraitInfo<ActorGroupProxy> { }
|
||||
|
||||
class ActorGroupProxy : IResolveOrder
|
||||
{
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "CreateGroup")
|
||||
{
|
||||
/* create a group */
|
||||
var actors = order.TargetString.Split(',')
|
||||
.Select(id => uint.Parse(id, NumberStyles.Any, NumberFormatInfo.InvariantInfo))
|
||||
.Select(id => self.World.Actors.FirstOrDefault(a => a.ActorID == id))
|
||||
.Where(a => a != null);
|
||||
|
||||
new Group(actors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
73
OpenRA.Mods.Common/Traits/Player/PlaceBeacon.cs
Normal file
73
OpenRA.Mods.Common/Traits/Player/PlaceBeacon.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class PlaceBeaconInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Duration = 30 * 25;
|
||||
public readonly string NotificationType = "Sounds";
|
||||
public readonly string Notification = "Beacon";
|
||||
public readonly string PalettePrefix = "player";
|
||||
|
||||
public object Create(ActorInitializer init) { return new PlaceBeacon(init.self, this); }
|
||||
}
|
||||
|
||||
public class PlaceBeacon : IResolveOrder
|
||||
{
|
||||
readonly PlaceBeaconInfo info;
|
||||
readonly RadarPings radarPings;
|
||||
|
||||
Beacon playerBeacon;
|
||||
RadarPing playerRadarPing;
|
||||
|
||||
public PlaceBeacon(Actor self, PlaceBeaconInfo info)
|
||||
{
|
||||
radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString != "PlaceBeacon")
|
||||
return;
|
||||
|
||||
var pos = self.World.Map.CenterOfCell(order.TargetLocation);
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (playerBeacon != null)
|
||||
self.World.Remove(playerBeacon);
|
||||
|
||||
playerBeacon = new Beacon(self.Owner, pos, info.Duration, info.PalettePrefix);
|
||||
self.World.Add(playerBeacon);
|
||||
|
||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
Sound.PlayNotification(self.World.Map.Rules, null, info.NotificationType, info.Notification,
|
||||
self.World.RenderPlayer != null ? self.World.RenderPlayer.Country.Race : null);
|
||||
|
||||
if (radarPings != null)
|
||||
{
|
||||
if (playerRadarPing != null)
|
||||
radarPings.Remove(playerRadarPing);
|
||||
|
||||
playerRadarPing = radarPings.Add(
|
||||
() => self.Owner.IsAlliedWith(self.World.RenderPlayer),
|
||||
pos,
|
||||
self.Owner.Color.RGB,
|
||||
info.Duration);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user