Merge pull request #7013 from atlimit8/ModsCommonScripting
Move the core of OpenRA.Mods.RA.Scripting to OpenRA.Mods.Common.Scripting
This commit is contained in:
@@ -21,6 +21,7 @@ namespace OpenRA.Mods.Common
|
||||
|
||||
public interface INotifyChat { bool OnChat(string from, string message); }
|
||||
public interface IRenderActorPreviewInfo { IEnumerable<IActorPreview> RenderPreview (ActorPreviewInitializer init); }
|
||||
public interface ICruiseAltitudeInfo { WRange GetCruiseAltitude(); }
|
||||
|
||||
public interface IUpgradable
|
||||
{
|
||||
|
||||
@@ -89,6 +89,24 @@
|
||||
<Compile Include="ServerTraits\LobbySettingsNotification.cs" />
|
||||
<Compile Include="ServerTraits\MasterServerPinger.cs" />
|
||||
<Compile Include="ServerTraits\PlayerPinger.cs" />
|
||||
<Compile Include="Scripting\CallLuaFunc.cs" />
|
||||
<Compile Include="Scripting\LuaScript.cs" />
|
||||
<Compile Include="Scripting\Media.cs" />
|
||||
<Compile Include="Scripting\ScriptTriggers.cs" />
|
||||
<Compile Include="Scripting\Global\ActorGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\CameraGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\CoordinateGlobals.cs" />
|
||||
<Compile Include="Scripting\Global\DateTimeGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\MapGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\MediaGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\PlayerGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\TriggerGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\UtilsGlobal.cs" />
|
||||
<Compile Include="Scripting\Properties\DiplomacyProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\HealthProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\PowerProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\ResourceProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\UpgradeProperties.cs" />
|
||||
<Compile Include="Traits\BlocksBullets.cs" />
|
||||
<Compile Include="Traits\Burns.cs" />
|
||||
<Compile Include="Traits\CustomBuildTimeValue.cs" />
|
||||
|
||||
@@ -13,7 +13,7 @@ using Eluant;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
public sealed class CallLuaFunc : Activity, IDisposable
|
||||
{
|
||||
@@ -10,13 +10,10 @@
|
||||
|
||||
using System.Linq;
|
||||
using Eluant;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("Actor")]
|
||||
public class ActorGlobal : ScriptGlobal
|
||||
@@ -78,8 +75,8 @@ namespace OpenRA.Scripting
|
||||
if (!context.World.Map.Rules.Actors.TryGetValue(type, out ai))
|
||||
throw new LuaException("Unknown actor type '{0}'".F(type));
|
||||
|
||||
var pi = ai.Traits.GetOrDefault<PlaneInfo>();
|
||||
return pi != null ? pi.CruiseAltitude.Range : 0;
|
||||
var pi = ai.Traits.GetOrDefault<ICruiseAltitudeInfo>();
|
||||
return pi != null ? pi.GetCruiseAltitude().Range : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("Camera")]
|
||||
public class CameraGlobal : ScriptGlobal
|
||||
@@ -7,8 +7,9 @@
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("CPos")]
|
||||
public class CPosGlobal : ScriptGlobal
|
||||
@@ -12,7 +12,7 @@ using System;
|
||||
using Eluant;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("DateTime")]
|
||||
public class DateGlobal : ScriptGlobal
|
||||
@@ -11,10 +11,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Eluant;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("Map")]
|
||||
public class MapGlobal : ScriptGlobal
|
||||
@@ -13,7 +13,7 @@ using System.Drawing;
|
||||
using Eluant;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("Media")]
|
||||
public class MediaGlobal : ScriptGlobal
|
||||
@@ -10,8 +10,9 @@
|
||||
|
||||
using System.Linq;
|
||||
using Eluant;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("Player")]
|
||||
public class PlayerGlobal : ScriptGlobal
|
||||
@@ -15,7 +15,7 @@ using Eluant;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("Trigger")]
|
||||
public class TriggerGlobal : ScriptGlobal
|
||||
@@ -13,7 +13,7 @@ using Eluant;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("Utils")]
|
||||
public class UtilsGlobal : ScriptGlobal
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Mods.Common;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[Desc("Part of the new Lua API.")]
|
||||
public class LuaScriptInfo : ITraitInfo, Requires<SpawnMapActorsInfo>
|
||||
@@ -12,7 +12,7 @@ using System;
|
||||
using System.IO;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
public static class Media
|
||||
{
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Network;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptPropertyGroup("Diplomacy")]
|
||||
public class DiplomacyProperties : ScriptPlayerProperties
|
||||
42
OpenRA.Mods.Common/Scripting/Properties/HealthProperties.cs
Normal file
42
OpenRA.Mods.Common/Scripting/Properties/HealthProperties.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
#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.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptPropertyGroup("General")]
|
||||
public class HealthProperties : ScriptActorProperties, Requires<HealthInfo>
|
||||
{
|
||||
Health health;
|
||||
public HealthProperties(ScriptContext context, Actor self)
|
||||
: base(context, self)
|
||||
{
|
||||
health = self.Trait<Health>();
|
||||
}
|
||||
|
||||
[Desc("Current health of the actor.")]
|
||||
public int Health
|
||||
{
|
||||
get { return health.HP; }
|
||||
set { health.InflictDamage(self, self, health.HP - value, null, true); }
|
||||
}
|
||||
|
||||
[Desc("Maximum health of the actor.")]
|
||||
public int MaxHealth { get { return health.MaxHP; } }
|
||||
|
||||
[Desc("Kill the actor.")]
|
||||
public void Kill()
|
||||
{
|
||||
health.InflictDamage(self, self, health.MaxHP, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Mods.Common.Power;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptPropertyGroup("Power")]
|
||||
public class PlayerPowerProperties : ScriptPlayerProperties, Requires<PowerManagerInfo>
|
||||
@@ -12,7 +12,7 @@ using System;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptPropertyGroup("Resources")]
|
||||
public class ResourceProperties : ScriptPlayerProperties, Requires<PlayerResourcesInfo>
|
||||
@@ -8,11 +8,10 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptPropertyGroup("General")]
|
||||
public class UpgradeProperties : ScriptActorProperties, Requires<UpgradeManagerInfo>
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Primitives;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
public enum Trigger { OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost,
|
||||
OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated, OnAddedToWorld, OnRemovedFromWorld };
|
||||
@@ -164,6 +164,7 @@
|
||||
<Compile Include="Buildings\LineBuild.cs" />
|
||||
<Compile Include="Buildings\RepairableBuilding.cs" />
|
||||
<Compile Include="Buildings\Util.cs" />
|
||||
<Compile Include="Scripting\Properties\RepairableBuildingProperties.cs" />
|
||||
<Compile Include="C4Demolition.cs" />
|
||||
<Compile Include="ExternalCapturable.cs" />
|
||||
<Compile Include="ExternalCapturableBar.cs" />
|
||||
@@ -238,7 +239,6 @@
|
||||
<Compile Include="Player\MissionObjectives.cs" />
|
||||
<Compile Include="PortableChrono.cs" />
|
||||
<Compile Include="Scripting\Properties\GuardProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\PlayerProperties.cs" />
|
||||
<Compile Include="Widgets\Logic\TabCompletionLogic.cs" />
|
||||
<Compile Include="Player\TechTree.cs" />
|
||||
<Compile Include="PrimaryBuilding.cs" />
|
||||
@@ -277,7 +277,6 @@
|
||||
<Compile Include="RepairsUnits.cs" />
|
||||
<Compile Include="Reservable.cs" />
|
||||
<Compile Include="ScaredyCat.cs" />
|
||||
<Compile Include="Scripting\Media.cs" />
|
||||
<Compile Include="SeedsResource.cs" />
|
||||
<Compile Include="SelfHealing.cs" />
|
||||
<Compile Include="Sellable.cs" />
|
||||
@@ -396,26 +395,14 @@
|
||||
<Compile Include="Widgets\Logic\ControlGroupLogic.cs" />
|
||||
<Compile Include="Buildings\LineBuildNode.cs" />
|
||||
<Compile Include="Render\WithBuildingPlacedAnimation.cs" />
|
||||
<Compile Include="Scripting\LuaScript.cs" />
|
||||
<Compile Include="Scripting\CallLuaFunc.cs" />
|
||||
<Compile Include="Scripting\Global\ActorGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\CoordinateGlobals.cs" />
|
||||
<Compile Include="Scripting\Properties\ResourceProperties.cs" />
|
||||
<Compile Include="Scripting\Global\ReinforcementsGlobal.cs" />
|
||||
<Compile Include="Scripting\Properties\ProductionProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\MissionObjectiveProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\MobileProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\GeneralProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\HealthProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\CombatProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\DiplomacyProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\PowerProperties.cs" />
|
||||
<Compile Include="Scripting\Global\MapGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\PlayerGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\UtilsGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\TriggerGlobal.cs" />
|
||||
<Compile Include="Scripting\ScriptTriggers.cs" />
|
||||
<Compile Include="Scripting\Properties\PlayerProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\TransportProperties.cs" />
|
||||
<Compile Include="Scripting\Global\CameraGlobal.cs" />
|
||||
<Compile Include="Scripting\Properties\ChronosphereProperties.cs" />
|
||||
<Compile Include="Render\WithRepairAnimation.cs" />
|
||||
<Compile Include="Render\WithRepairOverlay.cs" />
|
||||
@@ -449,7 +436,6 @@
|
||||
<Compile Include="Widgets\Logic\SupportPowerBinLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\DebugMenuLogic.cs" />
|
||||
<Compile Include="ProductionQueueFromSelection.cs" />
|
||||
<Compile Include="Scripting\Global\MediaGlobal.cs" />
|
||||
<Compile Include="GlobalUpgradable.cs" />
|
||||
<Compile Include="Player\GlobalUpgradeManager.cs" />
|
||||
<Compile Include="GainsStatUpgrades.cs" />
|
||||
@@ -457,8 +443,6 @@
|
||||
<Compile Include="Warheads\CreateResourceWarhead.cs" />
|
||||
<Compile Include="Warheads\DestroyResourceWarhead.cs" />
|
||||
<Compile Include="Warheads\PerCellDamageWarhead.cs" />
|
||||
<Compile Include="Scripting\Global\ReinforcementsGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\DateTimeGlobal.cs" />
|
||||
<Compile Include="Scripting\Properties\HarvesterProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\HelicopterProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\PlaneProperties.cs" />
|
||||
@@ -468,7 +452,6 @@
|
||||
<Compile Include="KillsSelf.cs" />
|
||||
<Compile Include="Warheads\GrantUpgradeWarhead.cs" />
|
||||
<Compile Include="Crates\GrantUpgradeCrateAction.cs" />
|
||||
<Compile Include="Scripting\Properties\UpgradeProperties.cs" />
|
||||
<Compile Include="UpgradeActorsNear.cs" />
|
||||
<Compile Include="WithRangeCircle.cs" />
|
||||
<Compile Include="Scripting\Properties\TransformProperties.cs" />
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using Eluant;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -13,6 +13,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.Common.Scripting;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -14,33 +14,6 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
{
|
||||
[ScriptPropertyGroup("General")]
|
||||
public class HealthProperties : ScriptActorProperties, Requires<HealthInfo>
|
||||
{
|
||||
Health health;
|
||||
public HealthProperties(ScriptContext context, Actor self)
|
||||
: base(context, self)
|
||||
{
|
||||
health = self.Trait<Health>();
|
||||
}
|
||||
|
||||
[Desc("Current health of the actor.")]
|
||||
public int Health
|
||||
{
|
||||
get { return health.HP; }
|
||||
set { health.InflictDamage(self, self, health.HP - value, null, true); }
|
||||
}
|
||||
|
||||
[Desc("Maximum health of the actor.")]
|
||||
public int MaxHealth { get { return health.MaxHP; } }
|
||||
|
||||
[Desc("Kill the actor.")]
|
||||
public void Kill()
|
||||
{
|
||||
health.InflictDamage(self, self, health.MaxHP, null, true);
|
||||
}
|
||||
}
|
||||
|
||||
[ScriptPropertyGroup("General")]
|
||||
public class RepairableBuildingProperties : ScriptActorProperties, Requires<RepairableBuildingInfo>
|
||||
{
|
||||
@@ -11,6 +11,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.Common.Orders;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
@@ -20,7 +21,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Traits
|
||||
{
|
||||
public class AircraftInfo : ITraitInfo, IFacingInfo, IOccupySpaceInfo, UsesInit<LocationInit>, UsesInit<FacingInit>
|
||||
public class AircraftInfo : ITraitInfo, IFacingInfo, IOccupySpaceInfo, ICruiseAltitudeInfo, UsesInit<LocationInit>, UsesInit<FacingInit>
|
||||
{
|
||||
public readonly WRange CruiseAltitude = new WRange(1280);
|
||||
public readonly WRange IdealSeparation = new WRange(1706);
|
||||
@@ -43,6 +44,7 @@ namespace OpenRA.Mods.RA.Traits
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new Aircraft(init, this); }
|
||||
public int GetInitialFacing() { return InitialFacing; }
|
||||
public WRange GetCruiseAltitude() { return CruiseAltitude; }
|
||||
}
|
||||
|
||||
public class Aircraft : IFacing, IPositionable, ISync, INotifyKilled, IIssueOrder, IOrderVoice, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Scripting;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.RA.Scripting;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
Reference in New Issue
Block a user