improves hitscan weapons (#248)

- fixes inhand sprite visibility
- adds visible charge level
- refactor sound recourse load, now you can specify fire sound from YAML
- adds laser cannon - more powerful laser
- adds new assets for cannon
This commit is contained in:
Injazz
2019-06-02 04:16:55 +05:00
committed by Pieter-Jan Briers
parent da35a0f3c9
commit 400778eb73
32 changed files with 349 additions and 11 deletions

View File

@@ -0,0 +1,33 @@
using Content.Shared.GameObjects.Components.Power;
using Content.Shared.Utility;
using Robust.Client.GameObjects;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Power
{
public class HitscanWeaponVisualizer2D : AppearanceVisualizer
{
private string _prefix;
public override void LoadData(YamlMappingNode node)
{
base.LoadData(node);
_prefix = node.GetNode("prefix").AsString();
}
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (component.TryGetData(PowerCellVisuals.ChargeLevel, out float fraction))
{
sprite.LayerSetState(0, $"{_prefix}_{ContentHelpers.RoundToLevels(fraction, 1, 5) * 25}");
}
}
}
}

View File

@@ -1,14 +1,27 @@
using System;
using Content.Shared.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Power;
using Robust.Shared.Serialization;
using Robust.Server.GameObjects;
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
{
public class HitscanWeaponCapacitorComponent : PowerCellComponent
{
private AppearanceComponent _appearance;
public override string Name => "HitscanWeaponCapacitor";
public override float Charge
{
get => base.Charge;
set
{
base.Charge = value;
_updateAppearance();
}
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
@@ -19,6 +32,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
base.Initialize();
Charge = Capacity;
Owner.TryGetComponent(out _appearance);
}
public float GetChargeFrom(float toDeduct)
@@ -27,6 +42,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
ChargeChanged();
var chargeChangedBy = Math.Min(this.Charge, toDeduct);
this.DeductCharge(chargeChangedBy);
_updateAppearance();
return chargeChangedBy;
}
@@ -43,6 +59,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
this.AddCharge(battery.Charge);
battery.DeductCharge(battery.Charge);
}
_updateAppearance();
}
private void _updateAppearance()
{
_appearance?.SetData(PowerCellVisuals.ChargeLevel, Charge / Capacity);
}
}

View File

@@ -29,6 +29,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
private int _damage;
private int _baseFireCost;
private float _lowerChargeLimit;
private string _fireSound;
//As this is a component that sits on the weapon rather than a static value
//we just declare the field and then use GetComponent later to actually get it.
@@ -46,10 +47,11 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
{
base.ExposeData(serializer);
serializer.DataField(ref _spritename, "sprite", "Objects/laser.png");
serializer.DataField(ref _spritename, "fireSprite", "Objects/laser.png");
serializer.DataField(ref _damage, "damage", 10);
serializer.DataField(ref _baseFireCost, "baseFireCost", 300);
serializer.DataField(ref _lowerChargeLimit, "lowerChargeLimit", 10);
serializer.DataField(ref _fireSound, "fireSound", "/Audio/laser.ogg");
}
public override void Initialize()
@@ -58,6 +60,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
var rangedWeapon = Owner.GetComponent<RangedWeaponComponent>();
capacitorComponent = Owner.GetComponent<HitscanWeaponCapacitorComponent>();
rangedWeapon.FireHandler = Fire;
}
public bool AttackBy(AttackByEventArgs eventArgs)
@@ -124,7 +127,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
};
var mgr = IoCManager.Resolve<IEntitySystemManager>();
mgr.GetEntitySystem<EffectSystem>().CreateParticle(message);
Owner.GetComponent<SoundComponent>().Play("/Audio/laser.ogg", AudioParams.Default.WithVolume(-5));
Owner.GetComponent<SoundComponent>().Play(_fireSound, AudioParams.Default.WithVolume(-5));
}
}
}

Binary file not shown.

View File

@@ -1,24 +1,59 @@
- type: entity
name: Laser Gun
name: Retro Laser Gun
parent: BaseItem
id: LaserItem
description: A weapon using light amplified by the stimulated emission of radiation
description: A weapon using light amplified by the stimulated emission of radiation. Ancient inefficient model.
components:
- type: Sprite
netsync: false
sprite: Objects/laser_retro.rsi
state: 100
state: laser_retro_100
- type: Icon
sprite: Objects/laser_retro.rsi
state: 100
state: laser_retro_100
- type: RangedWeapon
- type: HitscanWeapon
damage: 30
sprite: "Objects/laser.png"
fireSprite: "Objects/laser.png"
fireSound: "/Audio/laser.ogg"
lowerDischargeLimit: 10
- type: HitscanWeaponCapacitor
capacity: 1000
capacity: 1200
- type: Item
Size: 24
sprite: Objects/laser_retro.rsi
prefix: 100
- type: Sound
prefix: laser_retro_100
- type: Appearance
visuals:
- type: HitscanWeaponVisualizer2D
prefix: laser_retro
- type: Sound
- type: entity
name: Laser Cannon
parent: LaserItem
id: LCannon
description: With the L.A.S.E.R. cannon, the lasing medium is enclosed in a tube lined with uranium-235 and subjected to high neutron flux in a nuclear reactor core. This incredible technology may help YOU achieve high excitation rates with small laser volumes!
components:
- type: Sprite
netsync: false
sprite: Objects/laser_cannon.rsi
state: laser_cannon_100
- type: Icon
sprite: Objects/laser_cannon.rsi
state: laser_cannon_100
- type: HitscanWeapon
damage: 90
fireSprite: "Objects/heavylaser.png"
fireSound: "/Audio/lasercannonfire.ogg"
lowerDischargeLimit: 10
- type: HitscanWeaponCapacitor
capacity: 2400
- type: Item
Size: 32
sprite: Objects/laser_cannon.rsi
prefix: laser_cannon_100
- type: Appearance
visuals:
- type: HitscanWeaponVisualizer2D
prefix: laser_cannon

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

View File

@@ -0,0 +1,123 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CC-BY-SA-3.0",
"copyright": "Taken from https://github.com/vgstation-coders/vgstation13 at commit 125c975f1b3bf9826b37029e9ab5a5f89e975a7e",
"states": [
{
"name": "laser_cannon",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_cannon_100",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_cannon_75",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_cannon_50",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_cannon_25",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_cannon_0",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "0-inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "0-inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "25-inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "25-inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "50-inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "50-inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "75-inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "75-inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
}
]
}

View File

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 451 B

View File

Before

Width:  |  Height:  |  Size: 437 B

After

Width:  |  Height:  |  Size: 437 B

View File

Before

Width:  |  Height:  |  Size: 538 B

After

Width:  |  Height:  |  Size: 538 B

View File

Before

Width:  |  Height:  |  Size: 519 B

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

View File

Before

Width:  |  Height:  |  Size: 533 B

After

Width:  |  Height:  |  Size: 533 B

View File

Before

Width:  |  Height:  |  Size: 538 B

After

Width:  |  Height:  |  Size: 538 B

View File

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 536 B

View File

@@ -1 +1,123 @@
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/vgstation-coders/vgstation13 at commit 125c975f1b3bf9826b37029e9ab5a5f89e975a7e", "states": [{"name": "0", "directions": 1, "delays": [[1.0]]}, {"name": "0-inhand-left", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "0-inhand-right", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "100", "directions": 1, "delays": [[1.0]]}, {"name": "100-inhand-left", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "100-inhand-right", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "25", "directions": 1, "delays": [[1.0]]}, {"name": "25-inhand-left", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "25-inhand-right", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "50", "directions": 1, "delays": [[1.0]]}, {"name": "50-inhand-left", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "50-inhand-right", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "75", "directions": 1, "delays": [[1.0]]}, {"name": "75-inhand-left", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "75-inhand-right", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}]}
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CC-BY-SA-3.0",
"copyright": "Taken from https://github.com/vgstation-coders/vgstation13 at commit 125c975f1b3bf9826b37029e9ab5a5f89e975a7e",
"states": [
{
"name": "laser_retro",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_retro_100",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_retro_75",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_retro_50",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_retro_25",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "laser_retro_0",
"directions": 1,
"delays": [
[1.0]
]
},
{
"name": "inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "0-inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "0-inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "25-inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "25-inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "50-inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "50-inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "75-inhand-left",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
},
{
"name": "75-inhand-right",
"directions": 4,
"delays": [
[1.0], [1.0], [1.0], [1.0]
]
}
]
}