mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
CompState Cleanup (#308)
* Changed GameObjects.Component namespace back to GameObjects.Components namespace to prevent colliding with GameObjects.Component class. * Changed IComponent.HandleComponentState to use polymorphism instead of dynamic keyword. Cleaned up nesting in each implementation of IComponent.HandleComponentState. * Moved all shared ComponentStates to the SS14.Shared.GameObjects namespace to be more in line with client & server components. Made all ComponentStates immutable, as they should be.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
f7b1b9c4b6
commit
2e3315cd39
@@ -3,7 +3,6 @@ using SFML.System;
|
||||
using SS14.Client.Interfaces.GameObjects;
|
||||
using SS14.Client.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -5,8 +5,6 @@ using SS14.Client.Interfaces.GameObjects;
|
||||
using SS14.Client.Interfaces.Map;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Collidable;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -217,15 +215,17 @@ namespace SS14.Client.GameObjects
|
||||
component.AABB.Height / tileSize);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
if (state.CollisionEnabled != collisionEnabled)
|
||||
{
|
||||
if (state.CollisionEnabled)
|
||||
EnableCollision();
|
||||
else
|
||||
DisableCollision();
|
||||
}
|
||||
var newState = (CollidableComponentState) state;
|
||||
if (newState.CollisionEnabled == collisionEnabled)
|
||||
return;
|
||||
|
||||
if (newState.CollisionEnabled)
|
||||
EnableCollision();
|
||||
else
|
||||
DisableCollision();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects;
|
||||
|
||||
namespace SS14.Client.GameObjects
|
||||
{
|
||||
@@ -4,7 +4,6 @@ using SS14.Client.Interfaces.Collision;
|
||||
using SS14.Client.Interfaces.GameObjects;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Utility;
|
||||
@@ -1,8 +1,6 @@
|
||||
using SFML.System;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Direction;
|
||||
using SS14.Shared.Maths;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
@@ -62,9 +60,11 @@ namespace SS14.Client.GameObjects
|
||||
Owner.SendMessage(this, ComponentMessageType.MoveDirection, movedir);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
var dir = (Direction)state.Direction;
|
||||
var newState = (DirectionComponentState) state;
|
||||
var dir = newState.Direction;
|
||||
SetMoveDir(dir);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
using SFML.Graphics;
|
||||
using SFML.System;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Hitbox;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
|
||||
@@ -52,17 +50,12 @@ namespace SS14.Client.GameObjects
|
||||
Offset = new Vector2f();
|
||||
}
|
||||
|
||||
public override Type StateType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(HitboxComponentState);
|
||||
}
|
||||
}
|
||||
public override Type StateType => typeof(HitboxComponentState);
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
AABB = state.AABB;
|
||||
AABB = ((HitboxComponentState)state).AABB;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
using SS14.Client.Interfaces.Input;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
using System.Collections.Generic;
|
||||
@@ -3,8 +3,6 @@ using SFML.System;
|
||||
using SS14.Client.Interfaces.Lighting;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Light;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -83,11 +81,6 @@ namespace SS14.Client.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetState(LightState state)
|
||||
{
|
||||
_light.SetState(state);
|
||||
}
|
||||
|
||||
protected void SetMode(LightModeClass mode)
|
||||
{
|
||||
IoCManager.Resolve<ILightManager>().SetLightMode(mode, _light);
|
||||
@@ -116,16 +109,18 @@ namespace SS14.Client.GameObjects
|
||||
_light.SetMask(mask);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
if (_light.LightState != state.State)
|
||||
_light.SetState(state.State);
|
||||
if (_light.Color.R != state.ColorR || _light.Color.G != state.ColorG || _light.Color.B != state.ColorB)
|
||||
{
|
||||
SetColor(state.ColorR, state.ColorG, state.ColorB);
|
||||
}
|
||||
if (_mode != state.Mode)
|
||||
SetMode(state.Mode);
|
||||
var newState = (PointLightComponentState) state;
|
||||
if (_light.LightState != newState.State)
|
||||
_light.SetState(newState.State);
|
||||
|
||||
if (_light.Color.R != newState.ColorR || _light.Color.G != newState.ColorG || _light.Color.B != newState.ColorB)
|
||||
SetColor(newState.ColorR, newState.ColorG, newState.ColorB);
|
||||
|
||||
if (_mode != newState.Mode)
|
||||
SetMode(newState.Mode);
|
||||
}
|
||||
|
||||
protected void SetColor(int R, int G, int B)
|
||||
@@ -1,8 +1,6 @@
|
||||
using SFML.System;
|
||||
using SS14.Client.Interfaces.GameObjects;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Mover;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
@@ -3,7 +3,6 @@ using SFML.System;
|
||||
using SS14.Client.Interfaces.GameObjects;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
using SS14.Client.Interfaces.GameObjects;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Mover;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -55,26 +53,22 @@ namespace SS14.Client.GameObjects
|
||||
Owner.GetComponent<ITransformComponent>().Position = toPosition;
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
SetNewState(state);
|
||||
}
|
||||
var newState = (SlaveMoverComponentState) state;
|
||||
|
||||
private void SetNewState(SlaveMoverComponentState state)
|
||||
{
|
||||
if (_master == null && state.Master != null)
|
||||
{
|
||||
Attach((int)state.Master);
|
||||
}
|
||||
if (_master != null && state.Master == null)
|
||||
{
|
||||
if (_master == null && newState.Master != null)
|
||||
Attach((int) newState.Master);
|
||||
|
||||
if (_master != null && newState.Master == null)
|
||||
Detach();
|
||||
}
|
||||
if (_master != null && state.Master != null && _master.Uid != state.Master)
|
||||
{
|
||||
Detach();
|
||||
Attach((int)state.Master);
|
||||
}
|
||||
|
||||
if (_master == null || newState.Master == null || _master.Uid == newState.Master)
|
||||
return;
|
||||
|
||||
Detach();
|
||||
Attach((int) newState.Master);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Physics;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
|
||||
@@ -14,9 +12,10 @@ namespace SS14.Client.GameObjects
|
||||
|
||||
public override Type StateType => typeof(PhysicsComponentState);
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
Mass = state.Mass;
|
||||
Mass = ((PhysicsComponentState)state).Mass;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,6 @@ using SS14.Client.Interfaces.Map;
|
||||
using SS14.Client.Interfaces.Resource;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Renderable;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -386,22 +384,21 @@ namespace SS14.Client.GameObjects
|
||||
slaves.Remove(slavecompo);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
DrawDepth = state.DrawDepth;
|
||||
visible = state.Visible;
|
||||
if (sprite.Name != state.Name)
|
||||
SetSprite(state.Name);
|
||||
if (sprite.CurrentAnimationStateKey != state.CurrentAnimation)
|
||||
{
|
||||
if (state.CurrentAnimation == null)
|
||||
sprite.SetAnimationState("idle");
|
||||
else
|
||||
sprite.SetAnimationState(state.CurrentAnimation);
|
||||
}
|
||||
SetMaster((int?)state.MasterUid);
|
||||
var newState = (AnimatedSpriteComponentState) state;
|
||||
DrawDepth = newState.DrawDepth;
|
||||
visible = newState.Visible;
|
||||
if (sprite.Name != newState.Name)
|
||||
SetSprite(newState.Name);
|
||||
|
||||
sprite.SetLoop(state.Loop);
|
||||
if (sprite.CurrentAnimationStateKey != newState.CurrentAnimation)
|
||||
sprite.SetAnimationState(newState.CurrentAnimation ?? "idle");
|
||||
|
||||
SetMaster(newState.MasterUid);
|
||||
|
||||
sprite.SetLoop(newState.Loop);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ using SFML.System;
|
||||
using SS14.Client.Interfaces.Resource;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Renderable;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Utility;
|
||||
using System;
|
||||
@@ -197,15 +195,17 @@ namespace SS14.Client.GameObjects
|
||||
return !IsInHand && base.WasClicked(worldPos);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
var newState = (SpriteComponentState) state;
|
||||
base.HandleComponentState((SpriteComponentState)state);
|
||||
|
||||
if (state.BaseName != null && basename != state.BaseName)
|
||||
{
|
||||
basename = state.BaseName;
|
||||
LoadSprites();
|
||||
}
|
||||
if (newState.BaseName == null || basename == newState.BaseName)
|
||||
return;
|
||||
|
||||
basename = newState.BaseName;
|
||||
LoadSprites();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ using SFML.System;
|
||||
using SS14.Client.Graphics;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Renderable;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Utility;
|
||||
@@ -156,15 +154,15 @@ namespace SS14.Client.GameObjects
|
||||
new Vector2f(), currentBaseSprite);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
base.HandleComponentState((SpriteComponentState)state);
|
||||
var newState = (SpriteComponentState) state;
|
||||
base.HandleComponentState(state);
|
||||
|
||||
if (state.BaseName != null && _basename != state.BaseName)
|
||||
{
|
||||
_basename = state.BaseName;
|
||||
LoadSprites();
|
||||
}
|
||||
if (newState.BaseName == null || _basename == newState.BaseName) return;
|
||||
_basename = newState.BaseName;
|
||||
LoadSprites();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ using SS14.Client.Interfaces.GameObjects;
|
||||
using SS14.Client.Interfaces.Resource;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Particles;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -161,19 +159,19 @@ namespace SS14.Client.GameObjects
|
||||
_emitters[name].Emit = active;
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic _state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
ParticleSystemComponentState state = (ParticleSystemComponentState)_state;
|
||||
var newState = (ParticleSystemComponentState) state;
|
||||
|
||||
foreach (var a in state.emitters)
|
||||
{
|
||||
foreach (var a in newState.emitters)
|
||||
if (_emitters.ContainsKey(a.Key))
|
||||
SetParticleSystemActive(a.Key, a.Value);
|
||||
else
|
||||
AddParticleSystem(a.Key, a.Value);
|
||||
}
|
||||
|
||||
foreach (var toRemove in new List<string>(_emitters.Keys.Except<string>(state.emitters.Keys))) //Remove emitters that are not in the new state.
|
||||
//Remove emitters that are not in the new state.
|
||||
foreach (var toRemove in new List<string>(_emitters.Keys.Except(newState.emitters.Keys)))
|
||||
RemoveParticleSystem(toRemove);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ using SS14.Client.Interfaces.GameObjects;
|
||||
using SS14.Client.Interfaces.Resource;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Renderable;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -378,16 +376,17 @@ namespace SS14.Client.GameObjects
|
||||
slaves.Remove(slavecompo);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
DrawDepth = state.DrawDepth;
|
||||
if (state.SpriteKey != null && sprites.ContainsKey(state.SpriteKey) &&
|
||||
currentBaseSprite != sprites[state.SpriteKey])
|
||||
{
|
||||
SetSpriteByKey(state.SpriteKey);
|
||||
}
|
||||
var newState = (SpriteComponentState) state;
|
||||
DrawDepth = newState.DrawDepth;
|
||||
|
||||
visible = state.Visible;
|
||||
if (newState.SpriteKey != null && sprites.ContainsKey(newState.SpriteKey) &&
|
||||
currentBaseSprite != sprites[newState.SpriteKey])
|
||||
SetSpriteByKey(newState.SpriteKey);
|
||||
|
||||
visible = newState.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ using SFML.System;
|
||||
using SS14.Client.Graphics;
|
||||
using SS14.Client.Interfaces.Resource;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Renderable;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Utility;
|
||||
@@ -27,10 +25,11 @@ namespace SS14.Client.GameObjects
|
||||
|
||||
public override Type StateType => typeof(WearableAnimatedSpriteComponentState);
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
base.HandleComponentState((WearableAnimatedSpriteComponentState)state);
|
||||
IsCurrentlyWorn = state.IsCurrentlyWorn;
|
||||
base.HandleComponentState(state);
|
||||
IsCurrentlyWorn = ((WearableAnimatedSpriteComponentState) state).IsCurrentlyWorn;
|
||||
}
|
||||
|
||||
public void SetNotWornSprite(string spritename)
|
||||
@@ -2,8 +2,6 @@
|
||||
using SS14.Client.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Transform;
|
||||
using SS14.Shared.Interfaces.Configuration;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
@@ -64,18 +62,15 @@ namespace SS14.Client.GameObjects
|
||||
Position = new Vector2f();
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
SetNewState(state);
|
||||
}
|
||||
|
||||
private void SetNewState(TransformComponentState state)
|
||||
{
|
||||
lastState = state;
|
||||
states.Add(state);
|
||||
var newState = (TransformComponentState)state;
|
||||
lastState = newState;
|
||||
states.Add(newState);
|
||||
var interp = IoCManager.Resolve<IConfigurationManager>().GetCVar<float>("net.interpolation");
|
||||
//Remove all states older than the one just before the interp time.
|
||||
lerpStateFrom = states.Where(s => s.ReceivedTime <= state.ReceivedTime - interp).OrderByDescending(s => s.ReceivedTime).FirstOrDefault();
|
||||
lerpStateFrom = states.Where(s => s.ReceivedTime <= newState.ReceivedTime - interp).OrderByDescending(s => s.ReceivedTime).FirstOrDefault();
|
||||
if (lerpStateFrom != null)
|
||||
{
|
||||
lerpStateTo =
|
||||
@@ -87,12 +82,12 @@ namespace SS14.Client.GameObjects
|
||||
}
|
||||
else
|
||||
{
|
||||
lerpStateFrom = state;
|
||||
lerpStateTo = state;
|
||||
lerpStateFrom = newState;
|
||||
lerpStateTo = newState;
|
||||
}
|
||||
if (lastState.ForceUpdate)
|
||||
{
|
||||
Position = state.Position;
|
||||
Position = newState.Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using SFML.System;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Velocity;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
@@ -37,18 +35,18 @@ namespace SS14.Client.GameObjects
|
||||
Velocity = new Vector2f();
|
||||
}
|
||||
|
||||
public override void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
if (!Owner.HasComponent<PlayerInputMoverComponent>())
|
||||
SetNewState(state);
|
||||
}
|
||||
if (Owner.HasComponent<PlayerInputMoverComponent>())
|
||||
return;
|
||||
|
||||
private void SetNewState(VelocityComponentState state)
|
||||
{
|
||||
var newState = (VelocityComponentState)state;
|
||||
if (_lastState != null)
|
||||
_previousState = _lastState;
|
||||
_lastState = state;
|
||||
Velocity = new Vector2f(state.VelocityX, state.VelocityY);
|
||||
|
||||
_lastState = newState;
|
||||
Velocity = new Vector2f(newState.VelocityX, newState.VelocityY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using SS14.Shared.GameObjects.Components.Transform;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
|
||||
namespace SS14.Client.Interfaces.GameObjects.Components
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="GameController.cs" />
|
||||
<Compile Include="GameObjects\Component\ClientComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\ClientComponent.cs" />
|
||||
<Compile Include="Interfaces\GameObjects\IClientEntityManager.cs" />
|
||||
<Compile Include="Interfaces\IGameController.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
@@ -213,29 +213,29 @@
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
<Compile Include="GameObjects\AnimatedSprite.cs" />
|
||||
<Compile Include="GameObjects\Component\ClickableComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Collidable\CollidableComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Collidable\TriggerableComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Collider\ColliderComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Direction\DirectionComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Hitbox\HitboxComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Icon\IconComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Input\ContextMenuComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Light\PointLightComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Mover\PlayerInputMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Mover\BasicMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Mover\SlaveMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Physics\PhysicsComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\AnimatedSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\ParticleSystem.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\ParticleSystemComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\Speechbubble.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\WearableAnimatedSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\ItemSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\MobSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\SpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Transform\TransformComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Velocity\VelocityComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\ClickableComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Collidable\CollidableComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Collidable\TriggerableComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Collider\ColliderComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Direction\DirectionComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Hitbox\HitboxComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Icon\IconComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Input\ContextMenuComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Light\PointLightComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Mover\PlayerInputMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Mover\BasicMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Mover\SlaveMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Physics\PhysicsComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\AnimatedSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\ParticleSystem.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\ParticleSystemComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\Speechbubble.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\WearableAnimatedSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\ItemSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\MobSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\SpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Transform\TransformComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Velocity\VelocityComponent.cs" />
|
||||
<Compile Include="GameObjects\ContextMenuEntry.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\ParticleSystem.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\InputSystem.cs" />
|
||||
@@ -243,7 +243,7 @@
|
||||
<Compile Include="GameObjects\ClientEntityManager.cs" />
|
||||
<Compile Include="GameObjects\ClientEntityNetworkManager.cs" />
|
||||
<Compile Include="GameObjects\ClientComponentFactory.cs" />
|
||||
<Compile Include="GameObjects\Component\Input\KeyBindingInputComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Input\KeyBindingInputComponent.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\PhysicsSystem.cs" />
|
||||
<Compile Include="Reflection\ClientReflectionManager.cs" />
|
||||
<Compile Include="ResourceManagement\BaseResource.cs" />
|
||||
@@ -382,4 +382,4 @@
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="Exists('Microsoft.VisualStudio.DebuggerVisualizers.dll') ">$(DefineConstants);VS_DEBUGGERVISUALIZERS_EXISTS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,7 +1,6 @@
|
||||
using Lidgren.Network;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
@@ -1,8 +1,6 @@
|
||||
using Lidgren.Network;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Collidable;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Direction;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -1,8 +1,6 @@
|
||||
using SFML.Graphics;
|
||||
using SS14.Server.Interfaces.Map;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Hitbox;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Utility;
|
||||
using Component = SS14.Shared.GameObjects.Component;
|
||||
@@ -2,7 +2,6 @@
|
||||
using SS14.Server.GameObjects.Events;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using SS14.Server.Interfaces.Chat;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Light;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Utility;
|
||||
using System;
|
||||
@@ -1,7 +1,6 @@
|
||||
using SFML.System;
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
|
||||
@@ -3,7 +3,6 @@ using SFML.System;
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Mover;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -83,19 +81,10 @@ namespace SS14.Server.GameObjects
|
||||
Owner.GetComponent<ITransformComponent>().Position = toPosition;
|
||||
}
|
||||
|
||||
private ITransformComponent getTransform()
|
||||
{
|
||||
return Owner.GetComponent<ITransformComponent>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
var transform = getTransform();
|
||||
if (master == null)
|
||||
{
|
||||
return new SlaveMoverComponentState(transform.X, transform.Y, 0, 0);
|
||||
}
|
||||
return new SlaveMoverComponentState(transform.X, transform.Y, 0, 0, master.Uid);
|
||||
return master == null ? new SlaveMoverComponentState(null) : new SlaveMoverComponentState(master.Uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Particles;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -1,6 +1,4 @@
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Physics;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Utility;
|
||||
using System.Collections.Generic;
|
||||
@@ -1,7 +1,5 @@
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Renderable;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Utility;
|
||||
@@ -1,8 +1,6 @@
|
||||
using Lidgren.Network;
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Renderable;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
using System.Collections.Generic;
|
||||
@@ -1,6 +1,4 @@
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Renderable;
|
||||
using SS14.Shared.IoC;
|
||||
|
||||
namespace SS14.Server.GameObjects
|
||||
@@ -2,8 +2,6 @@
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Transform;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using System;
|
||||
@@ -1,7 +1,5 @@
|
||||
using SFML.System;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Components;
|
||||
using SS14.Shared.GameObjects.Components.Velocity;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
|
||||
@@ -193,23 +193,23 @@
|
||||
<Compile Include="GameObjects\ServerEntityManager.cs" />
|
||||
<Compile Include="GameObjects\ServerEntityNetworkManager.cs" />
|
||||
<Compile Include="GameObjects\MessageEnums.cs" />
|
||||
<Compile Include="GameObjects\Component\ClickableComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Actor\BasicActorComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Collidable\CollidableComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Direction\DirectionComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Hitbox\HitboxComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Input\KeyBindingInputComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Light\PointLightComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Mover\BasicMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Mover\PlayerInputMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Mover\SlaveMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Particles\ParticleSystemComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Physics\PhysicsComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\AnimatedSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\SpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\WearableAnimatedSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Transform\TransformComponent.cs" />
|
||||
<Compile Include="GameObjects\Component\Velocity\VelocityComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\ClickableComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Actor\BasicActorComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Collidable\CollidableComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Direction\DirectionComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Hitbox\HitboxComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Input\KeyBindingInputComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Light\PointLightComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Mover\BasicMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Mover\PlayerInputMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Mover\SlaveMoverComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Particles\ParticleSystemComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Physics\PhysicsComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\AnimatedSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\SpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\WearableAnimatedSpriteComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Transform\TransformComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Velocity\VelocityComponent.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\InputSystem.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\ParticleSystem.cs" />
|
||||
<Compile Include="GameObjects\EntitySystems\PhysicsSystem.cs" />
|
||||
@@ -270,4 +270,4 @@
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -15,8 +15,6 @@ namespace SS14.Shared.GameObjects
|
||||
public virtual uint? NetID => null;
|
||||
public virtual bool NetworkSynchronizeExistence => false;
|
||||
|
||||
#region IComponent Members
|
||||
|
||||
public IEntity Owner { get; private set; }
|
||||
public virtual Type StateType => typeof(ComponentState);
|
||||
|
||||
@@ -105,7 +103,8 @@ namespace SS14.Shared.GameObjects
|
||||
return new ComponentState(NetID.Value);
|
||||
}
|
||||
|
||||
public virtual void HandleComponentState(dynamic state)
|
||||
/// <inheritdoc />
|
||||
public virtual void HandleComponentState(ComponentState state)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -135,8 +134,6 @@ namespace SS14.Shared.GameObjects
|
||||
return new List<ComponentParameter>();
|
||||
}
|
||||
|
||||
#endregion IComponent Members
|
||||
|
||||
protected virtual void SubscribeEvents()
|
||||
{ }
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Direction
|
||||
{
|
||||
[Serializable]
|
||||
public class DirectionComponentState : ComponentState
|
||||
{
|
||||
public SS14.Shared.Direction Direction;
|
||||
|
||||
public DirectionComponentState(SS14.Shared.Direction dir)
|
||||
:base(NetIDs.DIRECTION)
|
||||
{
|
||||
Direction = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using SFML.Graphics;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Hitbox
|
||||
{
|
||||
/// <summary>
|
||||
/// Hitbox is defined as the hight/width Size and pixel offset.
|
||||
/// The center of the hitbox is on the center of the entity it is attached to.
|
||||
/// The offset adjusts the position of the center of the hitbox.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class HitboxComponentState : ComponentState
|
||||
{
|
||||
public FloatRect AABB;
|
||||
|
||||
public HitboxComponentState(FloatRect aabb)
|
||||
:base(NetIDs.HITBOX)
|
||||
{
|
||||
AABB = aabb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Mover
|
||||
{
|
||||
[Serializable]
|
||||
public class SlaveMoverComponentState : ComponentState
|
||||
{
|
||||
public float VelocityX;
|
||||
public float VelocityY;
|
||||
public float X;
|
||||
public float Y;
|
||||
public int? Master;
|
||||
|
||||
public SlaveMoverComponentState(float x, float y, float velx, float vely)
|
||||
:base(NetIDs.SLAVE_MOVER)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
VelocityX = velx;
|
||||
VelocityY = vely;
|
||||
}
|
||||
|
||||
public SlaveMoverComponentState(float x, float y, float velx, float vely, int master)
|
||||
: base(NetIDs.SLAVE_MOVER)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
VelocityX = velx;
|
||||
VelocityY = vely;
|
||||
Master = master;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Collidable
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class CollidableComponentState : ComponentState
|
||||
{
|
||||
public bool CollisionEnabled;
|
||||
public readonly bool CollisionEnabled;
|
||||
|
||||
public CollidableComponentState(bool collisionEnabled)
|
||||
: base(NetIDs.COLLIDABLE)
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class DirectionComponentState : ComponentState
|
||||
{
|
||||
public readonly Direction Direction;
|
||||
|
||||
public DirectionComponentState(Direction dir)
|
||||
: base(NetIDs.DIRECTION)
|
||||
{
|
||||
Direction = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using SFML.Graphics;
|
||||
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Hitbox is defined as the hight/width Size and pixel offset.
|
||||
/// The center of the hitbox is on the center of the entity it is attached to.
|
||||
/// The offset adjusts the position of the center of the hitbox.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class HitboxComponentState : ComponentState
|
||||
{
|
||||
public readonly FloatRect AABB;
|
||||
|
||||
public HitboxComponentState(FloatRect aabb)
|
||||
: base(NetIDs.HITBOX)
|
||||
{
|
||||
AABB = aabb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Light
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class PointLightComponentState : ComponentState
|
||||
{
|
||||
public int ColorB;
|
||||
public int ColorG;
|
||||
public int ColorR;
|
||||
public LightModeClass Mode;
|
||||
public LightState State;
|
||||
public readonly int ColorB;
|
||||
public readonly int ColorG;
|
||||
public readonly int ColorR;
|
||||
public readonly LightModeClass Mode;
|
||||
public readonly LightState State;
|
||||
|
||||
public PointLightComponentState(LightState state, int colorR, int colorG, int colorB, LightModeClass mode)
|
||||
: base(NetIDs.POINT_LIGHT)
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class SlaveMoverComponentState : ComponentState
|
||||
{
|
||||
public readonly int? Master;
|
||||
|
||||
public SlaveMoverComponentState(int? master)
|
||||
: base(NetIDs.SLAVE_MOVER)
|
||||
{
|
||||
Master = master;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace SS14.Shared.GameObjects.Components
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
public static class NetIDs
|
||||
{
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Particles
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class ParticleSystemComponentState : ComponentState
|
||||
{
|
||||
public Dictionary<string, Boolean> emitters;
|
||||
public readonly Dictionary<string, bool> emitters;
|
||||
|
||||
public ParticleSystemComponentState(Dictionary<string, Boolean> _emitters)
|
||||
public ParticleSystemComponentState(Dictionary<string, bool> _emitters)
|
||||
: base(NetIDs.PARTICLE_SYSTEM)
|
||||
{
|
||||
emitters = _emitters;
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Physics
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class PhysicsComponentState : ComponentState
|
||||
{
|
||||
public float Mass;
|
||||
public readonly float Mass;
|
||||
|
||||
public PhysicsComponentState(float mass)
|
||||
: base(NetIDs.PHYSICS)
|
||||
@@ -1,16 +1,17 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Renderable
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class AnimatedSpriteComponentState : RenderableComponentState
|
||||
{
|
||||
public string Name;
|
||||
public bool Visible;
|
||||
public string CurrentAnimation;
|
||||
public bool Loop;
|
||||
public readonly string CurrentAnimation;
|
||||
public readonly bool Loop;
|
||||
public readonly string Name;
|
||||
public readonly bool Visible;
|
||||
|
||||
public AnimatedSpriteComponentState(bool visible, DrawDepth drawDepth, string name, string currentAnimation, bool loop, int? masterUid)
|
||||
public AnimatedSpriteComponentState(bool visible, DrawDepth drawDepth, string name, string currentAnimation,
|
||||
bool loop, int? masterUid)
|
||||
: base(drawDepth, masterUid, NetIDs.ANIMATED_SPRITE)
|
||||
{
|
||||
Visible = visible;
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Renderable
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class RenderableComponentState : ComponentState
|
||||
{
|
||||
public DrawDepth DrawDepth;
|
||||
public int? MasterUid;
|
||||
public readonly DrawDepth DrawDepth;
|
||||
public readonly int? MasterUid;
|
||||
|
||||
public RenderableComponentState(DrawDepth drawDepth, int? masterUid, uint netID) :
|
||||
base(netID)
|
||||
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Renderable
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class SpriteComponentState : RenderableComponentState
|
||||
{
|
||||
public string BaseName;
|
||||
public string SpriteKey;
|
||||
public bool Visible;
|
||||
public readonly string BaseName;
|
||||
public readonly string SpriteKey;
|
||||
public readonly bool Visible;
|
||||
|
||||
public SpriteComponentState(bool visible, DrawDepth drawDepth, string spriteKey, string baseName)
|
||||
: base(drawDepth, null, NetIDs.SPRITE)
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Renderable
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class WearableAnimatedSpriteComponentState : AnimatedSpriteComponentState
|
||||
{
|
||||
public bool IsCurrentlyWorn;
|
||||
public bool IsCurrentlyCarried;
|
||||
public readonly bool IsCurrentlyWorn;
|
||||
public readonly bool IsCurrentlyCarried;
|
||||
|
||||
public WearableAnimatedSpriteComponentState(bool isCurrentlyWorn, bool isCurrentlyCarried, bool visible, DrawDepth drawDepth, string name, string currentAnimation, bool loop, int? masterUid)
|
||||
: base(visible, drawDepth, name, currentAnimation, loop, masterUid)
|
||||
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using SFML.System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Transform
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class TransformComponentState : ComponentState
|
||||
{
|
||||
public bool ForceUpdate { get; set; }
|
||||
public Vector2f Position { get; set; }
|
||||
public readonly bool ForceUpdate;
|
||||
public readonly Vector2f Position;
|
||||
|
||||
public TransformComponentState(Vector2f position, bool forceUpdate)
|
||||
: base(NetIDs.TRANSFORM)
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SS14.Shared.GameObjects.Components.Velocity
|
||||
namespace SS14.Shared.GameObjects
|
||||
{
|
||||
[Serializable]
|
||||
public class VelocityComponentState : ComponentState
|
||||
{
|
||||
public float VelocityX;
|
||||
public float VelocityY;
|
||||
public readonly float VelocityX;
|
||||
public readonly float VelocityY;
|
||||
|
||||
public VelocityComponentState(float velx, float vely)
|
||||
: base(NetIDs.VELOCITY)
|
||||
@@ -459,18 +459,17 @@ namespace SS14.Shared.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ComponentState compState in state.ComponentStates)
|
||||
foreach (var compState in state.ComponentStates)
|
||||
{
|
||||
compState.ReceivedTime = state.ReceivedTime;
|
||||
if (TryGetComponent(compState.NetID, out var component))
|
||||
{
|
||||
Type stateType = component.StateType;
|
||||
if (compState.GetType() != stateType)
|
||||
{
|
||||
throw new InvalidOperationException($"Incorrect component state type: {stateType}, component: {component.GetType()}");
|
||||
}
|
||||
component.HandleComponentState(compState);
|
||||
}
|
||||
|
||||
if (!TryGetComponent(compState.NetID, out var component))
|
||||
continue;
|
||||
|
||||
if (compState.GetType() != component.StateType)
|
||||
throw new InvalidOperationException($"Incorrect component state type: {component.StateType}, component: {component.GetType()}");
|
||||
|
||||
component.HandleComponentState(compState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,11 @@ namespace SS14.Shared.Interfaces.GameObjects
|
||||
bool NetworkSynchronizeExistence { get; }
|
||||
|
||||
IEntity Owner { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Class Type that deserializes this component. This is the type that GetComponentState returns,
|
||||
/// and is the type that is passed to HandleComponentState.
|
||||
/// </summary>
|
||||
Type StateType { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -89,7 +94,12 @@ namespace SS14.Shared.Interfaces.GameObjects
|
||||
ComponentState GetComponentState();
|
||||
|
||||
void HandleNetworkMessage(IncomingEntityComponentMessage message, NetConnection sender);
|
||||
void HandleComponentState(dynamic state);
|
||||
|
||||
/// <summary>
|
||||
/// Handles an incoming component state from the server.
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
void HandleComponentState(ComponentState state);
|
||||
|
||||
/// <summary>
|
||||
/// Handles a message that a client has just instantiated a component
|
||||
|
||||
@@ -250,19 +250,19 @@
|
||||
<Compile Include="GameObjects\System\EntityEventHandlingSystem.cs" />
|
||||
<Compile Include="GameObjects\System\EntityProcessingSystem.cs" />
|
||||
<Compile Include="GameObjects\System\EntitySystem.cs" />
|
||||
<Compile Include="GameObjects\Component\Collidable\CollidableComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Direction\DirectionComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Hitbox\HitboxComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Light\PointLightComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Mover\SlaveMoverComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Particles\ParticleSystemComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Physics\PhysicsComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\AnimatedSpriteComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\RenderableComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\SpriteComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Renderable\WearableAnimatedSpriteComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Transform\TransformComponentState.cs" />
|
||||
<Compile Include="GameObjects\Component\Velocity\VelocityComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Collidable\CollidableComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Direction\DirectionComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Hitbox\HitboxComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Light\PointLightComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Mover\SlaveMoverComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Particles\ParticleSystemComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Physics\PhysicsComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\AnimatedSpriteComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\RenderableComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\SpriteComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Renderable\WearableAnimatedSpriteComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Transform\TransformComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Velocity\VelocityComponentState.cs" />
|
||||
<Compile Include="GameObjects\EntitySystemMessage\EntitySystemMessage.cs" />
|
||||
<Compile Include="GameObjects\EntitySystemMessage\InventorySystemMessages.cs" />
|
||||
<Compile Include="GameObjects\Events\InputEvents.cs" />
|
||||
@@ -303,7 +303,7 @@
|
||||
<Content Include="Prototypes\Entities\Wallmounted.yml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Compile Include="GameObjects\Component\NetIDs.cs" />
|
||||
<Compile Include="GameObjects\Components\NetIDs.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
@@ -320,4 +320,4 @@
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user