Species Component (#130)
* Fix this fug oksure Creates the initial species component, damage states, and threshold templates and hooks them into the damageable component * More rebase fixes * test * Pre future rebase * Please * Lol * Lol2 * SHADERS * Update Engine * yml file * Fix an initialization issue, injects dependencies * Fix error in loading shaders * Makes a master character ui controller component added upon client attachment to entity and remove upon client detachment from entity * Fixes just about everytrhing * Address PJB's comments * geeze * Make overlays work in worldspace instead of screen space and not cover user interfaces * update submodule
This commit is contained in:
committed by
Pieter-Jan Briers
parent
b8becf4a56
commit
37df61113e
@@ -0,0 +1,61 @@
|
||||
using Content.Shared.GameObjects;
|
||||
using System;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Triggers an event when values rise above or drop below this threshold
|
||||
/// </summary>
|
||||
public struct DamageThreshold
|
||||
{
|
||||
public DamageType DamageType { get; }
|
||||
public int Value { get; }
|
||||
public ThresholdType ThresholdType { get; }
|
||||
|
||||
public DamageThreshold(DamageType damageType, int value, ThresholdType thresholdType)
|
||||
{
|
||||
DamageType = damageType;
|
||||
Value = value;
|
||||
ThresholdType = thresholdType;
|
||||
}
|
||||
|
||||
public override bool Equals(Object obj)
|
||||
{
|
||||
return obj is DamageThreshold && this == (DamageThreshold)obj;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return DamageType.GetHashCode() ^ Value.GetHashCode();
|
||||
}
|
||||
public static bool operator ==(DamageThreshold x, DamageThreshold y)
|
||||
{
|
||||
return x.DamageType == y.DamageType && x.Value == y.Value;
|
||||
}
|
||||
public static bool operator !=(DamageThreshold x, DamageThreshold y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ThresholdType
|
||||
{
|
||||
None,
|
||||
Destruction,
|
||||
Death,
|
||||
Critical,
|
||||
HUDUpdate
|
||||
}
|
||||
|
||||
public class DamageThresholdPassedEventArgs : EventArgs
|
||||
{
|
||||
public DamageThreshold DamageThreshold { get; }
|
||||
public bool Passed { get; }
|
||||
|
||||
public DamageThresholdPassedEventArgs(DamageThreshold threshold, bool passed)
|
||||
{
|
||||
DamageThreshold = threshold;
|
||||
Passed = passed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,11 @@ namespace Content.Server.GameObjects
|
||||
/// A component that handles receiving damage and healing,
|
||||
/// as well as informing other components of it.
|
||||
/// </summary>
|
||||
public class DamageableComponent : Component, IDamageableComponent
|
||||
public class DamageableComponent : SharedDamageableComponent, IDamageableComponent
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Name => "Damageable";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override uint? NetID => ContentNetIDs.DAMAGEABLE;
|
||||
|
||||
/// <summary>
|
||||
/// The resistance set of this object.
|
||||
/// Affects receiving damage of various types.
|
||||
@@ -33,11 +30,17 @@ namespace Content.Server.GameObjects
|
||||
[ViewVariables]
|
||||
public ResistanceSet Resistances { get; private set; }
|
||||
|
||||
Dictionary<DamageType, int> CurrentDamage = new Dictionary<DamageType, int>();
|
||||
Dictionary<DamageType, List<int>> Thresholds = new Dictionary<DamageType, List<int>>();
|
||||
public IReadOnlyDictionary<DamageType, int> CurrentDamage => _currentDamage;
|
||||
private Dictionary<DamageType, int> _currentDamage = new Dictionary<DamageType, int>();
|
||||
|
||||
Dictionary<DamageType, List<DamageThreshold>> Thresholds = new Dictionary<DamageType, List<DamageThreshold>>();
|
||||
|
||||
public event EventHandler<DamageThresholdPassedEventArgs> DamageThresholdPassed;
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new DamageComponentState(_currentDamage);
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
@@ -55,9 +58,10 @@ namespace Content.Server.GameObjects
|
||||
{
|
||||
base.Initialize();
|
||||
InitializeDamageType(DamageType.Total);
|
||||
if (Owner is IOnDamageBehavior damageBehavior)
|
||||
|
||||
foreach (var damagebehavior in Owner.GetAllComponents<IOnDamageBehavior>())
|
||||
{
|
||||
AddThresholdsFrom(damageBehavior);
|
||||
AddThresholdsFrom(damagebehavior);
|
||||
}
|
||||
|
||||
RecalculateComponentThresholds();
|
||||
@@ -72,7 +76,7 @@ namespace Content.Server.GameObjects
|
||||
}
|
||||
InitializeDamageType(damageType);
|
||||
|
||||
int oldValue = CurrentDamage[damageType];
|
||||
int oldValue = _currentDamage[damageType];
|
||||
int oldTotalValue = -1;
|
||||
|
||||
if (amount == 0)
|
||||
@@ -81,13 +85,13 @@ namespace Content.Server.GameObjects
|
||||
}
|
||||
|
||||
amount = Resistances.CalculateDamage(damageType, amount);
|
||||
CurrentDamage[damageType] = Math.Max(0, CurrentDamage[damageType] + amount);
|
||||
_currentDamage[damageType] = Math.Max(0, _currentDamage[damageType] + amount);
|
||||
UpdateForDamageType(damageType, oldValue);
|
||||
|
||||
if (Resistances.AppliesToTotal(damageType))
|
||||
{
|
||||
oldTotalValue = CurrentDamage[DamageType.Total];
|
||||
CurrentDamage[DamageType.Total] = Math.Max(0, CurrentDamage[DamageType.Total] + amount);
|
||||
oldTotalValue = _currentDamage[DamageType.Total];
|
||||
_currentDamage[DamageType.Total] = Math.Max(0, _currentDamage[DamageType.Total] + amount);
|
||||
UpdateForDamageType(DamageType.Total, oldTotalValue);
|
||||
}
|
||||
}
|
||||
@@ -104,7 +108,7 @@ namespace Content.Server.GameObjects
|
||||
|
||||
void UpdateForDamageType(DamageType damageType, int oldValue)
|
||||
{
|
||||
int change = CurrentDamage[damageType] - oldValue;
|
||||
int change = _currentDamage[damageType] - oldValue;
|
||||
|
||||
if (change == 0)
|
||||
{
|
||||
@@ -113,11 +117,12 @@ namespace Content.Server.GameObjects
|
||||
|
||||
int changeSign = Math.Sign(change);
|
||||
|
||||
foreach (int value in Thresholds[damageType])
|
||||
foreach (var threshold in Thresholds[damageType])
|
||||
{
|
||||
if (((value * changeSign) > (oldValue * changeSign)) && ((value * changeSign) <= (CurrentDamage[damageType] * changeSign)))
|
||||
var value = threshold.Value;
|
||||
if (((value * changeSign) > (oldValue * changeSign)) && ((value * changeSign) <= (_currentDamage[damageType] * changeSign)))
|
||||
{
|
||||
var args = new DamageThresholdPassedEventArgs(new DamageThreshold(damageType, value), (changeSign > 0));
|
||||
var args = new DamageThresholdPassedEventArgs(threshold, (changeSign > 0));
|
||||
DamageThresholdPassed?.Invoke(this, args);
|
||||
}
|
||||
}
|
||||
@@ -142,62 +147,23 @@ namespace Content.Server.GameObjects
|
||||
|
||||
foreach (DamageThreshold threshold in thresholds)
|
||||
{
|
||||
if (!Thresholds[threshold.DamageType].Contains(threshold.Value))
|
||||
if (!Thresholds[threshold.DamageType].Contains(threshold))
|
||||
{
|
||||
Thresholds[threshold.DamageType].Add(threshold.Value);
|
||||
Thresholds[threshold.DamageType].Add(threshold);
|
||||
}
|
||||
}
|
||||
|
||||
DamageThresholdPassed += onDamageBehavior.OnDamageThresholdPassed;
|
||||
}
|
||||
|
||||
void InitializeDamageType(DamageType damageType)
|
||||
{
|
||||
if (!CurrentDamage.ContainsKey(damageType))
|
||||
if (!_currentDamage.ContainsKey(damageType))
|
||||
{
|
||||
CurrentDamage.Add(damageType, 0);
|
||||
Thresholds.Add(damageType, new List<int>());
|
||||
_currentDamage.Add(damageType, 0);
|
||||
Thresholds.Add(damageType, new List<DamageThreshold>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct DamageThreshold
|
||||
{
|
||||
public DamageType DamageType { get; }
|
||||
public int Value { get; }
|
||||
|
||||
public DamageThreshold(DamageType damageType, int value)
|
||||
{
|
||||
DamageType = damageType;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public override bool Equals(Object obj)
|
||||
{
|
||||
return obj is DamageThreshold && this == (DamageThreshold)obj;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return DamageType.GetHashCode() ^ Value.GetHashCode();
|
||||
}
|
||||
public static bool operator ==(DamageThreshold x, DamageThreshold y)
|
||||
{
|
||||
return x.DamageType == y.DamageType && x.Value == y.Value;
|
||||
}
|
||||
public static bool operator !=(DamageThreshold x, DamageThreshold y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
}
|
||||
|
||||
public class DamageThresholdPassedEventArgs : EventArgs
|
||||
{
|
||||
public DamageThreshold DamageThreshold { get; }
|
||||
public bool Passed { get; }
|
||||
|
||||
public DamageThresholdPassedEventArgs(DamageThreshold threshold, bool passed)
|
||||
{
|
||||
DamageThreshold = threshold;
|
||||
Passed = passed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,18 +43,7 @@ namespace Content.Server.GameObjects
|
||||
serializer.DataReadFunction("thresholdtype", DamageType.Total, type => damageType = type);
|
||||
serializer.DataReadFunction("thresholdvalue", 0, val => damageValue = val);
|
||||
|
||||
Threshold = new DamageThreshold(damageType, damageValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (Owner.TryGetComponent<DamageableComponent>(out DamageableComponent damageable))
|
||||
{
|
||||
damageable.DamageThresholdPassed += OnDamageThresholdPassed;
|
||||
Threshold = new DamageThreshold(damageType, damageValue, ThresholdType.Destruction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,9 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Damage types used in-game.
|
||||
/// Total should never be used directly - it's a derived value.
|
||||
/// </summary>
|
||||
public enum DamageType
|
||||
{
|
||||
Total,
|
||||
Brute,
|
||||
Heat,
|
||||
Cold,
|
||||
Acid,
|
||||
Toxic,
|
||||
Electric
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resistance set used by damageable objects.
|
||||
/// For each damage type, has a coefficient, damage reduction and "included in total" value.
|
||||
|
||||
104
Content.Server/GameObjects/Components/Mobs/DamageStates.cs
Normal file
104
Content.Server/GameObjects/Components/Mobs/DamageStates.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using SS14.Server.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Maths;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the blocking effect of each damage state, and what effects to apply upon entering or exiting the state
|
||||
/// </summary>
|
||||
public interface DamageState : IActionBlocker
|
||||
{
|
||||
void EnterState(IEntity entity);
|
||||
|
||||
void ExitState(IEntity entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Standard state that a species is at with no damage or negative effect
|
||||
/// </summary>
|
||||
public struct NormalState : DamageState
|
||||
{
|
||||
public void EnterState(IEntity entity){}
|
||||
|
||||
public void ExitState(IEntity entity){}
|
||||
|
||||
bool IActionBlocker.CanInteract()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanMove()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanUse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A state in which you are disabled from acting due to damage
|
||||
/// </summary>
|
||||
public struct CriticalState : DamageState
|
||||
{
|
||||
public void EnterState(IEntity entity) { }
|
||||
|
||||
public void ExitState(IEntity entity) { }
|
||||
|
||||
bool IActionBlocker.CanInteract()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanMove()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanUse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A damage state which will allow ghosting out of mobs
|
||||
/// </summary>
|
||||
public struct DeadState : DamageState
|
||||
{
|
||||
public void EnterState(IEntity entity)
|
||||
{
|
||||
if(entity.TryGetComponent(out SpriteComponent sprite))
|
||||
{
|
||||
sprite.Rotation = sprite.Rotation + Angle.FromDegrees(90);
|
||||
}
|
||||
}
|
||||
|
||||
public void ExitState(IEntity entity)
|
||||
{
|
||||
if (entity.TryGetComponent(out SpriteComponent sprite))
|
||||
{
|
||||
sprite.Rotation = sprite.Rotation - Angle.FromDegrees(90);
|
||||
}
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanInteract()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanMove()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanUse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the threshold values for each damage state for any kind of species
|
||||
/// </summary>
|
||||
public abstract class DamageTemplates
|
||||
{
|
||||
public abstract List<DamageThreshold> HealthHudThresholds { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Changes the hud state when a threshold is reached
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="damage"></param>
|
||||
/// <returns></returns>
|
||||
public abstract HudStateChange ChangeHudState(DamageableComponent damage);
|
||||
|
||||
//public abstract ResistanceSet resistanceset { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Shows allowed states, ordered by priority, closest to last value to have threshold reached is preferred
|
||||
/// </summary>
|
||||
public abstract List<(DamageType, int, ThresholdType)> AllowedStates { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Map of ALL POSSIBLE damage states to the threshold enum value that will trigger them, normal state wont be triggered by this value but is a default that is fell back onto
|
||||
/// </summary>
|
||||
public static Dictionary<ThresholdType, DamageState> StateThresholdMap = new Dictionary<ThresholdType, DamageState>()
|
||||
{
|
||||
{ ThresholdType.None, new NormalState() },
|
||||
{ ThresholdType.Critical, new CriticalState() },
|
||||
{ ThresholdType.Death, new DeadState() }
|
||||
};
|
||||
|
||||
public List<DamageThreshold> DamageThresholds
|
||||
{
|
||||
get
|
||||
{
|
||||
List<DamageThreshold> thresholds = new List<DamageThreshold>();
|
||||
foreach (var element in AllowedStates)
|
||||
{
|
||||
thresholds.Add(new DamageThreshold(element.Item1, element.Item2, element.Item3));
|
||||
}
|
||||
return thresholds;
|
||||
}
|
||||
}
|
||||
|
||||
public ThresholdType CalculateDamageState(DamageableComponent damage)
|
||||
{
|
||||
ThresholdType healthstate = ThresholdType.None;
|
||||
foreach(var element in AllowedStates)
|
||||
{
|
||||
if(damage.CurrentDamage[element.Item1] >= element.Item2)
|
||||
{
|
||||
healthstate = element.Item3;
|
||||
}
|
||||
}
|
||||
|
||||
return healthstate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using Content.Shared.GameObjects;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
public class Human : DamageTemplates
|
||||
{
|
||||
int critvalue = 200;
|
||||
int normalstates = 6;
|
||||
//string startsprite = "human0";
|
||||
|
||||
public override List<(DamageType, int, ThresholdType)> AllowedStates => new List<(DamageType, int, ThresholdType)>()
|
||||
{
|
||||
(DamageType.Total, critvalue, ThresholdType.Critical),
|
||||
(DamageType.Total, 300, ThresholdType.Death),
|
||||
};
|
||||
|
||||
public override List<DamageThreshold> HealthHudThresholds
|
||||
{
|
||||
get
|
||||
{
|
||||
List<DamageThreshold> thresholds = new List<DamageThreshold>();
|
||||
thresholds.Add(new DamageThreshold(DamageType.Total, 1, ThresholdType.HUDUpdate));
|
||||
for (var i = 1; i <= normalstates; i++)
|
||||
{
|
||||
thresholds.Add(new DamageThreshold(DamageType.Total, i * critvalue / normalstates, ThresholdType.HUDUpdate));
|
||||
}
|
||||
return thresholds; //we don't need to respecify the state damage thresholds since we'll update hud on damage state changes as well
|
||||
}
|
||||
}
|
||||
|
||||
public override HudStateChange ChangeHudState(DamageableComponent damage)
|
||||
{
|
||||
ThresholdType healthstate = CalculateDamageState(damage);
|
||||
switch (healthstate)
|
||||
{
|
||||
case ThresholdType.None:
|
||||
var totaldamage = damage.CurrentDamage[DamageType.Total];
|
||||
if (totaldamage > critvalue)
|
||||
{
|
||||
throw new System.InvalidOperationException(); //these should all be below the crit value, possibly going over multiple thresholds at once?
|
||||
}
|
||||
var modifier = totaldamage / (critvalue / normalstates); //integer division floors towards zero
|
||||
return new HudStateChange()
|
||||
{
|
||||
StateSprite = "Mob/UI/Human/human" + modifier.ToString() + ".png",
|
||||
effect = ScreenEffects.None
|
||||
};
|
||||
case ThresholdType.Critical:
|
||||
return new HudStateChange()
|
||||
{
|
||||
StateSprite = "Mob/UI/Human/humancrit-0.png", //TODO: display as gif or alternate with -0 and -1 as frames
|
||||
effect = ScreenEffects.GradientCircleMask
|
||||
};
|
||||
case ThresholdType.Death:
|
||||
return new HudStateChange()
|
||||
{
|
||||
StateSprite = "Mob/UI/Human/humandead.png",
|
||||
effect = ScreenEffects.CircleMask
|
||||
};
|
||||
default:
|
||||
throw new System.InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs
Normal file
114
Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.GameObjects;
|
||||
using SS14.Server.GameObjects;
|
||||
using SS14.Shared.ContentPack;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.Network;
|
||||
using SS14.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
public class SpeciesComponent : Component, IActionBlocker, IOnDamageBehavior
|
||||
{
|
||||
public override string Name => "Species";
|
||||
|
||||
public override uint? NetID => ContentNetIDs.SPECIES;
|
||||
|
||||
/// <summary>
|
||||
/// Damagestates are reached by reaching a certain damage threshold, they will block actions after being reached
|
||||
/// </summary>
|
||||
public DamageState CurrentDamageState { get; private set; } = new NormalState();
|
||||
|
||||
/// <summary>
|
||||
/// Damage state enum for current health, set only via change damage state //TODO: SETTER
|
||||
/// </summary>
|
||||
private ThresholdType currentstate = ThresholdType.None;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the damage template which controls the threshold and resistance settings for this species type
|
||||
/// </summary>
|
||||
private DamageTemplates DamageTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// Variable for serialization
|
||||
/// </summary>
|
||||
private string templatename;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref templatename, "Template", "Human");
|
||||
|
||||
Type type = AppDomain.CurrentDomain.GetAssemblyByName("Content.Server").GetType("Content.Server.GameObjects." + templatename);
|
||||
DamageTemplate = (DamageTemplates)Activator.CreateInstance(type);
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
var hudstatechange = DamageTemplate.ChangeHudState(Owner.GetComponent<DamageableComponent>());
|
||||
SendNetworkMessage(hudstatechange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanMove()
|
||||
{
|
||||
return CurrentDamageState.CanMove();
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanInteract()
|
||||
{
|
||||
return CurrentDamageState.CanInteract();
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanUse()
|
||||
{
|
||||
return CurrentDamageState.CanUse();
|
||||
}
|
||||
|
||||
List<DamageThreshold> IOnDamageBehavior.GetAllDamageThresholds()
|
||||
{
|
||||
var thresholdlist = DamageTemplate.DamageThresholds;
|
||||
thresholdlist.AddRange(DamageTemplate.HealthHudThresholds);
|
||||
return thresholdlist;
|
||||
}
|
||||
|
||||
void IOnDamageBehavior.OnDamageThresholdPassed(object damageable, DamageThresholdPassedEventArgs e)
|
||||
{
|
||||
DamageableComponent damage = (DamageableComponent)damageable;
|
||||
|
||||
if(e.DamageThreshold.ThresholdType != ThresholdType.HUDUpdate)
|
||||
{
|
||||
ChangeDamageState(DamageTemplate.CalculateDamageState(damage));
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out BasicActorComponent actor)) //specifies if we have a client to update the hud for
|
||||
{
|
||||
var hudstatechange = DamageTemplate.ChangeHudState(damage);
|
||||
SendNetworkMessage(hudstatechange);
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeDamageState(ThresholdType threshold)
|
||||
{
|
||||
if(threshold == currentstate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentDamageState.ExitState(Owner);
|
||||
CurrentDamageState = DamageTemplates.StateThresholdMap[threshold];
|
||||
CurrentDamageState.EnterState(Owner);
|
||||
|
||||
currentstate = threshold;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
using SS14.Shared.Utility;
|
||||
using Content.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Projectiles
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Projectiles;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.Physics;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
|
||||
@@ -11,6 +11,7 @@ using SS14.Shared.Interfaces.Timing;
|
||||
using SS14.Shared.GameObjects.EntitySystemMessages;
|
||||
using SS14.Shared.Serialization;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using Content.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using SS14.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects;
|
||||
using SS14.Server.GameObjects.EntitySystems;
|
||||
using SS14.Shared.Audio;
|
||||
using SS14.Shared.GameObjects.EntitySystemMessages;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
@@ -9,6 +10,7 @@ using SS14.Shared.IoC;
|
||||
using SS14.Shared.Map;
|
||||
using SS14.Shared.Maths;
|
||||
using SS14.Shared.Physics;
|
||||
using SS14.Shared.Serialization;
|
||||
using System;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
|
||||
@@ -18,7 +20,16 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
|
||||
private const float MaxLength = 20;
|
||||
public override string Name => "HitscanWeapon";
|
||||
|
||||
private const string SpriteName = "Objects/laser.png";
|
||||
string Spritename = "Objects/laser.png";
|
||||
int Damage = 10;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref Spritename, "sprite", "Objects/laser.png");
|
||||
serializer.DataField(ref Damage, "damage", 10);
|
||||
}
|
||||
|
||||
protected override void Fire(IEntity user, GridLocalCoordinates clicklocation)
|
||||
{
|
||||
@@ -37,7 +48,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
|
||||
{
|
||||
if (ray.HitEntity != null && ray.HitEntity.TryGetComponent(out DamageableComponent damage))
|
||||
{
|
||||
damage.TakeDamage(DamageType.Heat, 10);
|
||||
damage.TakeDamage(DamageType.Heat, Damage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +59,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
|
||||
var offset = angle.ToVec() * dist / 2;
|
||||
var message = new EffectSystemMessage
|
||||
{
|
||||
EffectSprite = SpriteName,
|
||||
EffectSprite = Spritename,
|
||||
Born = time,
|
||||
DeathTime = time + TimeSpan.FromSeconds(1),
|
||||
Size = new Vector2(dist, 1f),
|
||||
|
||||
Reference in New Issue
Block a user