Power improvements:
* crashes fixed * made lights an RSI.
This commit is contained in:
@@ -129,7 +129,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
public override void Shutdown()
|
||||
{
|
||||
if (Owner.TryGetComponent(out PowerNodeComponent node))
|
||||
{
|
||||
@@ -143,20 +143,25 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
node.OnPowernetRegenerate -= PowernetRegenerate;
|
||||
}
|
||||
|
||||
base.OnRemove();
|
||||
if (Provider != null)
|
||||
{
|
||||
Provider.RemoveDevice(this);
|
||||
}
|
||||
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
public override void LoadParameters(YamlMappingNode mapping)
|
||||
{
|
||||
if (mapping.TryGetNode("Drawtype", out YamlNode node))
|
||||
if (mapping.TryGetNode("drawtype", out YamlNode node))
|
||||
{
|
||||
DrawType = node.AsEnum<DrawTypes>();
|
||||
}
|
||||
if (mapping.TryGetNode("Load", out node))
|
||||
if (mapping.TryGetNode("load", out node))
|
||||
{
|
||||
Load = node.AsFloat();
|
||||
}
|
||||
if (mapping.TryGetNode("Priority", out node))
|
||||
if (mapping.TryGetNode("priority", out node))
|
||||
{
|
||||
Priority = node.AsEnum<Powernet.Priority>();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
|
||||
public override void LoadParameters(YamlMappingNode mapping)
|
||||
{
|
||||
if (mapping.TryGetNode("Supply", out YamlNode node))
|
||||
if (mapping.TryGetNode("supply", out YamlNode node))
|
||||
{
|
||||
Supply = node.AsFloat();
|
||||
}
|
||||
|
||||
@@ -31,27 +31,38 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
/// </summary>
|
||||
public SortedSet<PowerDeviceComponent> DeviceLoadList = new SortedSet<PowerDeviceComponent>(new Powernet.DevicePriorityCompare());
|
||||
|
||||
/// <summary>
|
||||
/// List of devices in range that we "advertised" to.
|
||||
/// </summary>
|
||||
public HashSet<PowerDeviceComponent> AdvertisedDevices = new HashSet<PowerDeviceComponent>();
|
||||
|
||||
public List<PowerDeviceComponent> DepoweredDevices = new List<PowerDeviceComponent>();
|
||||
|
||||
public override Powernet.Priority Priority { get; protected set; } = Powernet.Priority.Provider;
|
||||
|
||||
public override void OnRemove()
|
||||
public PowerProviderComponent()
|
||||
{
|
||||
base.OnRemove();
|
||||
Load = 0;
|
||||
}
|
||||
|
||||
foreach (var device in DeviceLoadList)
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
foreach (var device in AdvertisedDevices.ToList())
|
||||
{
|
||||
device.RemoveProvider(this);
|
||||
}
|
||||
AdvertisedDevices.Clear();
|
||||
}
|
||||
|
||||
public override void LoadParameters(YamlMappingNode mapping)
|
||||
{
|
||||
if (mapping.TryGetNode("Range", out YamlNode node))
|
||||
if (mapping.TryGetNode("range", out YamlNode node))
|
||||
{
|
||||
PowerRange = node.AsInt();
|
||||
}
|
||||
if (mapping.TryGetNode("Priority", out node))
|
||||
if (mapping.TryGetNode("priority", out node))
|
||||
{
|
||||
Priority = node.AsEnum<Powernet.Priority>();
|
||||
}
|
||||
@@ -138,8 +149,12 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
|
||||
//Make sure the device can accept power providers to give it power
|
||||
if (device.DrawType == DrawTypes.Provider || device.DrawType == DrawTypes.Both)
|
||||
{
|
||||
if (!AdvertisedDevices.Contains(device))
|
||||
{
|
||||
device.AddProvider(this);
|
||||
AdvertisedDevices.Add(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,10 +165,11 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
base.PowernetDisconnect(sender, eventarg);
|
||||
|
||||
//We don't want to make the devices under us think we're still a valid provider if we have no powernet to connect to
|
||||
foreach (var device in DeviceLoadList.ToList())
|
||||
foreach (var device in AdvertisedDevices.ToList())
|
||||
{
|
||||
device.RemoveProvider(this);
|
||||
}
|
||||
AdvertisedDevices.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -194,7 +210,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
else
|
||||
{
|
||||
var name = device.Owner.Prototype.Name;
|
||||
Logger.Info(String.Format("We tried to remove a device twice from the same {0} somehow, prototype {1}", Name, name));
|
||||
Logger.WarningS("power", "We tried to remove a device twice from the same {0} somehow, prototype {1}", Name, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,23 +60,23 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
|
||||
public override void LoadParameters(YamlMappingNode mapping)
|
||||
{
|
||||
if (mapping.TryGetNode("Capacity", out YamlNode node))
|
||||
if (mapping.TryGetNode("capacity", out YamlNode node))
|
||||
{
|
||||
Capacity = node.AsFloat();
|
||||
}
|
||||
if (mapping.TryGetNode("Charge", out node))
|
||||
if (mapping.TryGetNode("charge", out node))
|
||||
{
|
||||
Charge = node.AsFloat();
|
||||
}
|
||||
if (mapping.TryGetNode("ChargeRate", out node))
|
||||
if (mapping.TryGetNode("chargerate", out node))
|
||||
{
|
||||
ChargeRate = node.AsFloat();
|
||||
}
|
||||
if (mapping.TryGetNode("DistributionRate", out node))
|
||||
if (mapping.TryGetNode("distributionrate", out node))
|
||||
{
|
||||
DistributionRate = node.AsFloat();
|
||||
}
|
||||
if (mapping.TryGetNode("ChargePowernet", out node))
|
||||
if (mapping.TryGetNode("chargepowernet", out node))
|
||||
{
|
||||
_chargepowernet = node.AsBool();
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
{
|
||||
if (args.Powered)
|
||||
{
|
||||
sprite.LayerSetTexture(0, "Objects/wall_light.png");
|
||||
sprite.LayerSetState(0, "on");
|
||||
light.State = LightState.On;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetTexture(0, "Objects/wall_light_off.png");
|
||||
sprite.LayerSetState(0, "off");
|
||||
light.State = LightState.Off;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
else
|
||||
{
|
||||
var name = device.Owner.Prototype.Name;
|
||||
Logger.Info(String.Format("We tried to remove a device twice from the same powernet somehow, prototype {0}", name));
|
||||
Logger.Info("We tried to remove a device twice from the same powernet somehow, prototype {0}", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,9 +55,9 @@
|
||||
- type: Icon
|
||||
texture: Objects/provider.png
|
||||
- type: PowerProvider
|
||||
Range: 5
|
||||
Priority: Provider
|
||||
Load: 0
|
||||
range: 5
|
||||
priority: Provider
|
||||
load: 0
|
||||
|
||||
- type: entity
|
||||
parent: WPPnobattery
|
||||
@@ -66,10 +66,10 @@
|
||||
description: Supplies power at range, has a backup battery just in case
|
||||
components:
|
||||
- type: PowerStorage
|
||||
Capacity: 1000
|
||||
Charge: 1000
|
||||
ChargeRate: 200
|
||||
ChargePowernet: false
|
||||
capacity: 1000
|
||||
charge: 1000
|
||||
chargerate: 200
|
||||
chargepowernet: false
|
||||
|
||||
|
||||
- type: entity
|
||||
@@ -86,11 +86,11 @@
|
||||
- type: Icon
|
||||
texture: Objects/storage.png
|
||||
- type: PowerStorage
|
||||
Capacity: 3000
|
||||
Charge: 1000
|
||||
ChargeRate: 200
|
||||
DistributionRate: 400
|
||||
ChargePowernet: true
|
||||
capacity: 3000
|
||||
charge: 1000
|
||||
chargerate: 200
|
||||
distributionrate: 400
|
||||
chargepowernet: true
|
||||
|
||||
- type: entity
|
||||
id: WiredMachine
|
||||
@@ -106,9 +106,9 @@
|
||||
- type: Icon
|
||||
texture: Objects/wiredmachine.png
|
||||
- type: PowerDevice
|
||||
Drawtype: Node
|
||||
Load: 100
|
||||
Priority: High
|
||||
drawtype: Node
|
||||
load: 100
|
||||
priority: High
|
||||
|
||||
- type: entity
|
||||
id: WirelessMachine
|
||||
@@ -124,6 +124,6 @@
|
||||
- type: Icon
|
||||
texture: Objects/wirelessmachine.png
|
||||
- type: PowerDevice
|
||||
Drawtype: Both
|
||||
Load: 200
|
||||
Priority: Low
|
||||
drawtype: Both
|
||||
load: 200
|
||||
priority: Low
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
- type: entity
|
||||
name: Light
|
||||
id: poweredlight
|
||||
parent: __engine_wall_light
|
||||
components:
|
||||
- type: Transform
|
||||
- type: Clickable
|
||||
# So we can click on it for deletion.
|
||||
- type: BoundingBox
|
||||
- type: Sprite
|
||||
texture: Objects/wall_light_off.png
|
||||
sprite: Objects/lighting.rsi
|
||||
state: off
|
||||
|
||||
- type: Icon
|
||||
sprite: Objects/lighting.rsi
|
||||
state: off
|
||||
|
||||
- type: PointLight
|
||||
state: Off
|
||||
radius: 8
|
||||
energy: 1.2
|
||||
offset: "0, -16"
|
||||
color: "#DCDCC6"
|
||||
|
||||
- type: PowerDevice
|
||||
load: 1
|
||||
load: 50
|
||||
priority: Low
|
||||
|
||||
- type: PoweredLight
|
||||
- type: PointLight
|
||||
state: Off
|
||||
|
||||
21
Resources/Textures/Objects/lighting.rsi/meta.json
Normal file
21
Resources/Textures/Objects/lighting.rsi/meta.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"states": [
|
||||
{
|
||||
"name": "on",
|
||||
"select": [],
|
||||
"flags": {},
|
||||
"directions": 4
|
||||
},
|
||||
{
|
||||
"name": "off",
|
||||
"select": [],
|
||||
"flags": {},
|
||||
"directions": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/Objects/lighting.rsi/off.png
Normal file
BIN
Resources/Textures/Objects/lighting.rsi/off.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 576 B |
BIN
Resources/Textures/Objects/lighting.rsi/on.png
Normal file
BIN
Resources/Textures/Objects/lighting.rsi/on.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 842 B |
2
engine
2
engine
Submodule engine updated: 3728c7eeee...b761d9a1eb
Reference in New Issue
Block a user