Welding tool, plasma cutter & misc item fixes/improvements
This commit is contained in:
@@ -356,7 +356,7 @@ namespace Subsurface
|
||||
/// <summary>
|
||||
/// Control the characte
|
||||
/// </summary>
|
||||
public void Control(Camera cam, bool forcePick=false)
|
||||
public void Control(float deltaTime, Camera cam, bool forcePick=false)
|
||||
{
|
||||
if (isDead) return;
|
||||
|
||||
@@ -383,15 +383,15 @@ namespace Subsurface
|
||||
if (selectedItems[i] == null) continue;
|
||||
if (i == 1 && selectedItems[0] == selectedItems[1]) continue;
|
||||
|
||||
if (actionKeyDown.State) selectedItems[i].Use(this);
|
||||
if (secondaryKeyDown.State && selectedItems[i] != null) selectedItems[i].SecondaryUse(this);
|
||||
if (actionKeyDown.State) selectedItems[i].Use(deltaTime, this);
|
||||
if (secondaryKeyDown.State && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
|
||||
|
||||
}
|
||||
|
||||
if (selectedConstruction != null)
|
||||
{
|
||||
if (actionKeyDown.State) selectedConstruction.Use(this);
|
||||
if (secondaryKeyDown.State) selectedConstruction.SecondaryUse(this);
|
||||
if (actionKeyDown.State) selectedConstruction.Use(deltaTime, this);
|
||||
if (secondaryKeyDown.State) selectedConstruction.SecondaryUse(deltaTime, this);
|
||||
}
|
||||
|
||||
if (IsNetworkPlayer)
|
||||
@@ -522,8 +522,8 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
if (controlled == this) ControlLocalPlayer(cam);
|
||||
|
||||
Control(cam);
|
||||
|
||||
Control(deltaTime, cam);
|
||||
|
||||
UpdateSightRange();
|
||||
aiTarget.SoundRange = 0.0f;
|
||||
@@ -781,7 +781,7 @@ namespace Subsurface
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, false);
|
||||
}
|
||||
|
||||
if (Game1.GameSession.crewManager!=null)
|
||||
if (Game1.GameSession!=null && Game1.GameSession.crewManager != null)
|
||||
{
|
||||
Game1.GameSession.crewManager.KillCharacter(this);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@ namespace Subsurface
|
||||
private Item item;
|
||||
|
||||
private Character character;
|
||||
|
||||
private Limb limb;
|
||||
|
||||
|
||||
public float Timer
|
||||
{
|
||||
get { return timer; }
|
||||
@@ -28,13 +26,12 @@ namespace Subsurface
|
||||
delay = ToolBox.GetAttributeFloat(element, "delay", 1.0f);
|
||||
}
|
||||
|
||||
public override void Apply(ActionType type, float deltaTime, Item item, Character character = null, Limb limb = null)
|
||||
public override void Apply(ActionType type, float deltaTime, Item item, Character character = null)
|
||||
{
|
||||
if (this.type != type) return;
|
||||
|
||||
this.item = item;
|
||||
this.character = character;
|
||||
this.limb = limb;
|
||||
|
||||
timer = delay;
|
||||
|
||||
@@ -47,7 +44,7 @@ namespace Subsurface
|
||||
|
||||
if (timer > 0.0f) return;
|
||||
|
||||
base.Apply(1.0f, character, item, limb);
|
||||
base.Apply(1.0f, character, item);
|
||||
list.Remove(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
@@ -10,7 +11,7 @@ namespace Subsurface
|
||||
[Flags]
|
||||
public enum Target
|
||||
{
|
||||
This = 1, Parent = 2, Character = 4, Contained = 8, Nearby = 16
|
||||
This = 1, Parent = 2, Character = 4, Contained = 8, Nearby = 16, UseTarget=32
|
||||
}
|
||||
|
||||
private Target targets;
|
||||
@@ -142,14 +143,34 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
public virtual void Apply(ActionType type, float deltaTime, Item item, Character character = null, Limb limb = null)
|
||||
public virtual void Apply(ActionType type, float deltaTime, Item item, Character character = null)
|
||||
{
|
||||
if (this.type == type) Apply(deltaTime, character, item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected virtual void Apply(float deltaTime, Character character, Item item, Limb limb = null)
|
||||
public virtual void Apply(ActionType type, float deltaTime, Vector2 position, IPropertyObject target)
|
||||
{
|
||||
if (!targetNames.Contains(target.Name)) return;
|
||||
if (this.type == type) Apply(deltaTime, position, target);
|
||||
}
|
||||
|
||||
protected virtual void Apply(float deltaTime, Vector2 position, IPropertyObject target)
|
||||
{
|
||||
if (explosion != null) explosion.Explode(position);
|
||||
|
||||
if (sound != null) sound.Play(1.0f, 1000.0f, position);
|
||||
|
||||
for (int i = 0; i < propertyNames.Count(); i++)
|
||||
{
|
||||
ObjectProperty property;
|
||||
if (target.ObjectProperties.TryGetValue(propertyNames[i], out property))
|
||||
{
|
||||
ApplyToProperty(property, propertyEffects[i], deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Apply(float deltaTime, Character character, Item item)
|
||||
{
|
||||
if (explosion != null) explosion.Explode(item.SimPosition);
|
||||
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
<Wearable limbtype="Head" slots="Any,Head">
|
||||
<sprite texture="DivingMask.png" limb="Head" sourcerect="1,1,37,38"/>
|
||||
<StatusEffect type="OnWearing" target="Contained,Character" targetnames="Oxygen Tank" Condition="-0.7" Oxygen="20.0"/>
|
||||
<StatusEffect type="OnWearing" target="Contained,Character" targetnames="Welding Fuel Tank" Condition="-0.7" Oxygen="-20.0"/>
|
||||
</Wearable>
|
||||
|
||||
<ItemContainer capacity="1" hideitems="true">
|
||||
<Containable name="Oxygen Tank"/>
|
||||
<Containable name="Welding Fuel Tank"/>
|
||||
</ItemContainer>
|
||||
|
||||
</Item>
|
||||
|
||||
|
Before Width: | Height: | Size: 464 B After Width: | Height: | Size: 464 B |
BIN
Subsurface/Content/Items/Tools/fueltank.png
Normal file
BIN
Subsurface/Content/Items/Tools/fueltank.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 474 B |
BIN
Subsurface/Content/Items/Tools/plasmacutter.png
Normal file
BIN
Subsurface/Content/Items/Tools/plasmacutter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -7,16 +7,64 @@
|
||||
|
||||
<Sprite texture ="weldingtool.png" depth="0.04"/>
|
||||
|
||||
<Body width="50" height="44" density="5"/>
|
||||
<Body width="39" height="18" density="5"/>
|
||||
|
||||
<Holdable holdpos="-9,-20" holdangle="-30"/>
|
||||
<Holdable aimpos="50,0" handle1="-17,0" handle2="8,0"/>
|
||||
|
||||
<RepairTool range="80">
|
||||
<RepairTool structurefixamount="50.0" range="80" barrelpos="19,8">
|
||||
<RequiredItems name="Welding Fuel Tank" type="Contained"/>
|
||||
<StatusEffect type="OnUse" target="Contained" targetnames="Welding Fuel Tank" Condition="-0.7"/>
|
||||
<StatusEffect type="OnUse" target="UseTarget" targetnames="Door,Windowed Door" Stuck="10.0"/>
|
||||
|
||||
<Fixable name="structure"/>
|
||||
</RepairTool>
|
||||
|
||||
<Pickable slots="Any,RightHand"/>
|
||||
<Pickable slots="Any,BothHands"/>
|
||||
|
||||
<ItemContainer capacity="1" hideitems="false" itempos="-17,-21">
|
||||
<Containable name="Welding Fuel Tank"/>
|
||||
<Containable name="Oxygen Tank"/>
|
||||
</ItemContainer>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
name="Plasma Cutter"
|
||||
Tags="smallitem"
|
||||
pickdistance="200">
|
||||
|
||||
<Sprite texture ="plasmacutter.png" depth="0.04"/>
|
||||
|
||||
<Body width="39" height="18" density="5"/>
|
||||
|
||||
<Holdable aimpos="50,0" handle1="-12,4"/>
|
||||
|
||||
<RepairTool structurefixamount="-10.0" range="50" barrelpos="19,8">
|
||||
<RequiredItems name="Oxygen Tank" type="Contained"/>
|
||||
<StatusEffect type="OnUse" target="Contained" targetnames="Oxygen Tank" Condition="-0.7"/>
|
||||
<StatusEffect type="OnUse" target="UseTarget" targetnames="Door,Windowed Door" Stuck="-10.0"/>
|
||||
|
||||
<Fixable name="structure"/>
|
||||
</RepairTool>
|
||||
|
||||
<Pickable slots="Any,RightHand,LeftHand"/>
|
||||
|
||||
<ItemContainer capacity="1" hideitems="false" itempos="9,-15">
|
||||
<Containable name="Welding Fuel Tank"/>
|
||||
<Containable name="Oxygen Tank"/>
|
||||
</ItemContainer>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
name="Welding Fuel Tank"
|
||||
Tags="smallitem"
|
||||
pickdistance="150">
|
||||
|
||||
<Sprite texture ="fueltank.png" depth="0.05"/>
|
||||
|
||||
<Body radius="6" height="22" density="5"/>
|
||||
|
||||
<Holdable holdpos="30,-15" handle1="0,5" handle2="0,-5"/>
|
||||
<Pickable slots="RightHand,Any"/>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 307 B |
@@ -70,4 +70,15 @@
|
||||
inwater="false"
|
||||
deleteonhit="true"
|
||||
velocitychange="0.0, 0.5"/>
|
||||
|
||||
<weld sprite="Content/Particles/explosion.png"
|
||||
startsizemin="0.1,0.1" startsizemax="0.2,0.2"
|
||||
sizechangemin="0.5,0.5" sizechangemax="0.7,0.7"
|
||||
startrotationmin ="0.0" startrotationmax="6.28"
|
||||
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
|
||||
colorchange="0.0, 0.0, -1.0, -5.0"
|
||||
lifetime="1.0"
|
||||
inwater="false"
|
||||
deleteonhit="true"
|
||||
velocitychange="0.0, 0.0"/>
|
||||
</prefabs>
|
||||
|
||||
@@ -4,6 +4,11 @@ namespace Subsurface
|
||||
{
|
||||
interface IPropertyObject
|
||||
{
|
||||
string Name
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
Dictionary<string, ObjectProperty> ObjectProperties
|
||||
{
|
||||
get;
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
if (hideItems) return;
|
||||
if (hideItems || (item.body!=null && !item.body.Enabled)) return;
|
||||
|
||||
Vector2 transformedItemPos = itemPos;
|
||||
Vector2 transformedItemInterval = itemInterval;
|
||||
@@ -175,7 +175,7 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
item.body.Enabled = true;
|
||||
//item.body.Enabled = true;
|
||||
|
||||
Matrix transform = Matrix.CreateRotationZ(item.body.Rotation);
|
||||
|
||||
|
||||
@@ -134,14 +134,14 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Use(Character activator = null)
|
||||
public override bool Use(float deltaTime, Character activator = null)
|
||||
{
|
||||
character = activator;
|
||||
foreach (MapEntity e in item.linkedTo)
|
||||
{
|
||||
Item linkedItem = e as Item;
|
||||
if (linkedItem == null) continue;
|
||||
linkedItem.Use(activator);
|
||||
linkedItem.Use(deltaTime, activator);
|
||||
}
|
||||
|
||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
@@ -149,7 +149,7 @@ namespace Subsurface.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SecondaryUse(Character character = null)
|
||||
public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character == null) return;
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
Item linkedItem = e as Item;
|
||||
if (linkedItem == null) continue;
|
||||
linkedItem.SecondaryUse(character);
|
||||
linkedItem.SecondaryUse(deltaTime, character);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,21 @@ namespace Subsurface.Items.Components
|
||||
ConvexHull convexHull;
|
||||
ConvexHull convexHull2;
|
||||
|
||||
private float stuck;
|
||||
public float Stuck
|
||||
{
|
||||
get { return stuck; }
|
||||
set
|
||||
{
|
||||
if (isOpen) return;
|
||||
stuck = MathHelper.Clamp(value, 0.0f, 100.0f);
|
||||
if (stuck == 0.0f) isStuck = false;
|
||||
if (stuck == 100.0f) isStuck = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isStuck;
|
||||
|
||||
Gap LinkedGap
|
||||
{
|
||||
get
|
||||
@@ -35,8 +50,9 @@ namespace Subsurface.Items.Components
|
||||
return linkedGap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool isOpen;
|
||||
|
||||
float openState;
|
||||
|
||||
[HasDefaultValue("0.0,0.0,0.0,0.0", false)]
|
||||
@@ -293,6 +309,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender)
|
||||
{
|
||||
if (isStuck) return;
|
||||
|
||||
if (connection.name=="toggle")
|
||||
{
|
||||
isOpen = !isOpen;
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Subsurface.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Use(Character character = null)
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (!attachable || item.body==null) return false;
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
if (attached) Use();
|
||||
if (attached) Use(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ namespace Subsurface
|
||||
switch (subElement.Name.ToString().ToLower())
|
||||
{
|
||||
case "requireditem":
|
||||
case "requireditems":
|
||||
RelatedItem ri = RelatedItem.Load(subElement);
|
||||
if (ri != null) requiredItems.Add(ri);
|
||||
break;
|
||||
@@ -264,13 +265,13 @@ namespace Subsurface
|
||||
|
||||
//called when the item is equipped and left mouse button is pressed
|
||||
//returns true if the item was used succesfully (not out of ammo, reloading, etc)
|
||||
public virtual bool Use(Character character = null)
|
||||
public virtual bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//called when the item is equipped and right mouse button is pressed
|
||||
public virtual void SecondaryUse(Character character = null) { }
|
||||
public virtual void SecondaryUse(float deltaTime, Character character = null) { }
|
||||
|
||||
//called when the item is placed in a "limbslot"
|
||||
public virtual void Equip(Character character) { }
|
||||
@@ -347,12 +348,21 @@ namespace Subsurface
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, Limb limb = null)
|
||||
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null)
|
||||
{
|
||||
foreach (StatusEffect effect in statusEffects)
|
||||
{
|
||||
if (effect.type != type) continue;
|
||||
item.ApplyStatusEffect(effect, type, deltaTime, character, limb);
|
||||
item.ApplyStatusEffect(effect, type, deltaTime, character);
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyStatusEffects(ActionType type, float deltaTime, Vector2 position, IPropertyObject target)
|
||||
{
|
||||
foreach (StatusEffect effect in statusEffects)
|
||||
{
|
||||
if (effect.type != type) continue;
|
||||
effect.Apply(type, deltaTime, position, target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Subsurface.Items.Components
|
||||
if (!picker.HasSelectedItem(item) && item.body!=null) item.body.Enabled = false;
|
||||
this.picker = picker;
|
||||
|
||||
ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker, null);
|
||||
ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
|
||||
|
||||
//foreach (StatusEffect effect in item.Prefab.statusEffects)
|
||||
//{
|
||||
|
||||
@@ -75,11 +75,11 @@ namespace Subsurface.Items.Components
|
||||
|
||||
//}
|
||||
|
||||
public override bool Use(Character character = null)
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character != null && !characterUsable) return false;
|
||||
|
||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
//ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
|
||||
Debug.WriteLine(item.body.Rotation);
|
||||
|
||||
|
||||
@@ -14,10 +14,11 @@ namespace Subsurface.Items.Components
|
||||
|
||||
private Vector2 barrelPos;
|
||||
|
||||
//[Initable(new Vector2(0.0f, 0.0f))]
|
||||
public Vector2 BarrelPos
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string BarrelPos
|
||||
{
|
||||
get { return new Vector2(barrelPos.X * item.body.Dir, barrelPos.Y); }
|
||||
get { return ToolBox.Vector2ToString(ConvertUnits.ToDisplayUnits(barrelPos)); }
|
||||
set { barrelPos = ConvertUnits.ToSimUnits(ToolBox.ParseToVector2(value)); }
|
||||
}
|
||||
|
||||
public Vector2 TransformedBarrelPos
|
||||
@@ -25,7 +26,9 @@ namespace Subsurface.Items.Components
|
||||
get
|
||||
{
|
||||
Matrix bodyTransform = Matrix.CreateRotationZ(item.body.Rotation);
|
||||
return (Vector2.Transform(BarrelPos, bodyTransform) + item.body.Position);
|
||||
Vector2 flippedPos = barrelPos;
|
||||
if (item.body.Dir < 0.0f) flippedPos.X = -flippedPos.X;
|
||||
return (Vector2.Transform(flippedPos, bodyTransform) + item.body.Position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +50,7 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Use(Character character = null)
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character == null) return false;
|
||||
if (!character.SecondaryKeyDown.State || reload > 0.0f) return false;
|
||||
@@ -78,7 +81,7 @@ namespace Subsurface.Items.Components
|
||||
projectile.SetTransform(TransformedBarrelPos,
|
||||
(item.body.Dir == 1.0f) ? item.body.Rotation : item.body.Rotation - MathHelper.Pi);
|
||||
|
||||
projectile.Use();
|
||||
projectile.Use(deltaTime);
|
||||
item.RemoveContained(projectile);
|
||||
|
||||
//recoil
|
||||
|
||||
@@ -5,6 +5,7 @@ using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Subsurface.Particles;
|
||||
|
||||
namespace Subsurface.Items.Components
|
||||
{
|
||||
@@ -16,29 +17,49 @@ namespace Subsurface.Items.Components
|
||||
|
||||
Vector2 pickedPosition;
|
||||
|
||||
Vector2 barrelPos;
|
||||
|
||||
float structureFixAmount, limbFixAmount;
|
||||
|
||||
[HasDefaultValue(100.0f, false)]
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
public float Range
|
||||
{
|
||||
get { return ConvertUnits.ToDisplayUnits(range); }
|
||||
set { range = ConvertUnits.ToSimUnits(value); }
|
||||
}
|
||||
|
||||
[HasDefaultValue(1.0f, false)]
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
public float StructureFixAmount
|
||||
{
|
||||
get { return structureFixAmount; }
|
||||
set { structureFixAmount = value; }
|
||||
}
|
||||
|
||||
[HasDefaultValue(1.0f, false)]
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
public float LimbFixAmount
|
||||
{
|
||||
get { return limbFixAmount; }
|
||||
set { limbFixAmount = value; }
|
||||
}
|
||||
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string BarrelPos
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(ConvertUnits.ToDisplayUnits(barrelPos)); }
|
||||
set { barrelPos = ConvertUnits.ToSimUnits(ToolBox.ParseToVector2(value)); }
|
||||
}
|
||||
|
||||
public Vector2 TransformedBarrelPos
|
||||
{
|
||||
get
|
||||
{
|
||||
Matrix bodyTransform = Matrix.CreateRotationZ(item.body.Rotation);
|
||||
Vector2 flippedPos = barrelPos;
|
||||
if (item.body.Dir < 0.0f) flippedPos.X = -flippedPos.X;
|
||||
return (Vector2.Transform(flippedPos, bodyTransform) + item.body.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public RepairTool(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
@@ -69,16 +90,18 @@ namespace Subsurface.Items.Components
|
||||
|
||||
//}
|
||||
|
||||
public override bool Use(Character character = null)
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character == null) return false;
|
||||
|
||||
isActive = true;
|
||||
|
||||
Vector2 targetPosition = item.body.Position;
|
||||
//targetPosition = targetPosition.X, -targetPosition.Y);
|
||||
|
||||
targetPosition += new Vector2(
|
||||
(float)Math.Cos(item.body.Rotation) * range,
|
||||
(float)Math.Sin(item.body.Rotation) * range) * item.body.Dir;
|
||||
(float)Math.Cos(item.body.Rotation),
|
||||
(float)Math.Sin(item.body.Rotation)) * range * item.body.Dir;
|
||||
|
||||
List<Body> ignoredBodies = new List<Body>();
|
||||
foreach (Limb limb in character.animController.limbs)
|
||||
@@ -86,13 +109,12 @@ namespace Subsurface.Items.Components
|
||||
ignoredBodies.Add(limb.body.FarseerBody);
|
||||
}
|
||||
|
||||
|
||||
Body targetBody = Map.PickBody(item.body.Position, targetPosition, ignoredBodies);
|
||||
Body targetBody = Map.PickBody(TransformedBarrelPos, targetPosition, ignoredBodies);
|
||||
pickedPosition = Map.LastPickedPosition;
|
||||
|
||||
if (targetBody==null || targetBody.UserData==null) return false;
|
||||
if (targetBody==null || targetBody.UserData==null) return true;
|
||||
|
||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
//ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
|
||||
|
||||
Structure targetStructure;
|
||||
@@ -100,18 +122,14 @@ namespace Subsurface.Items.Components
|
||||
Item targetItem;
|
||||
if ((targetStructure = (targetBody.UserData as Structure)) != null)
|
||||
{
|
||||
if (!fixableEntities.Contains(targetStructure.Name)) return false;
|
||||
if (!fixableEntities.Contains(targetStructure.Name)) return true;
|
||||
|
||||
int sectionIndex = targetStructure.FindSectionIndex(ConvertUnits.ToDisplayUnits(pickedPosition));
|
||||
if (sectionIndex < 0) return false;
|
||||
if (sectionIndex < 0) return true;
|
||||
|
||||
targetStructure.HighLightSection(sectionIndex);
|
||||
|
||||
if (character.SecondaryKeyDown.State)
|
||||
{
|
||||
targetStructure.AddDamage(sectionIndex, -structureFixAmount);
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if ((targetLimb = (targetBody.UserData as Limb)) != null)
|
||||
@@ -119,26 +137,55 @@ namespace Subsurface.Items.Components
|
||||
if (character.SecondaryKeyDown.State)
|
||||
{
|
||||
targetLimb.character.Health += limbFixAmount;
|
||||
isActive = true;
|
||||
//isActive = true;
|
||||
}
|
||||
}
|
||||
else if ((targetItem = (targetBody.UserData as Item)) !=null)
|
||||
else if ((targetItem = (targetBody.UserData as Item)) != null)
|
||||
{
|
||||
targetItem.Condition -= structureFixAmount;
|
||||
//targetItem.Condition -= structureFixAmount;
|
||||
targetItem.IsHighlighted = true;
|
||||
|
||||
foreach (StatusEffect effect in statusEffects)
|
||||
{
|
||||
if (Array.IndexOf(effect.TargetNames, targetItem.Name) == -1) continue;
|
||||
effect.Apply(ActionType.OnUse, deltaTime, targetItem);
|
||||
//targetItem.ApplyStatusEffect(effect, ActionType.OnUse, deltaTime);
|
||||
}
|
||||
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
|
||||
}
|
||||
|
||||
//if (character.SecondaryKeyDown.State)
|
||||
//{
|
||||
// IPropertyObject propertyObject = targetBody.UserData as IPropertyObject;
|
||||
// if (propertyObject!=null) ApplyStatusEffects(ActionType.OnUse, 1.0f, item.SimPosition, propertyObject);
|
||||
// //isActive = true;
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
base.Update(deltaTime, cam);
|
||||
|
||||
//isActive = true;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!isActive) return;
|
||||
|
||||
Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position);
|
||||
Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition);
|
||||
endPos = new Vector2(endPos.X + Game1.localRandom.Next(-2, 2), endPos.Y + Game1.localRandom.Next(-2, 2));
|
||||
Vector2 particleSpeed = new Vector2(
|
||||
(float)Math.Cos(item.body.Rotation),
|
||||
(float)Math.Sin(item.body.Rotation)) *item.body.Dir * 5.0f;
|
||||
|
||||
GUI.DrawLine(spriteBatch, startPos, endPos, Color.Orange, 0.0f);
|
||||
Game1.particleManager.CreateParticle("weld", TransformedBarrelPos, particleSpeed);
|
||||
|
||||
//Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position);
|
||||
//Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition);
|
||||
//endPos = new Vector2(endPos.X + Game1.localRandom.Next(-2, 2), endPos.Y + Game1.localRandom.Next(-2, 2));
|
||||
|
||||
//GUI.DrawLine(spriteBatch, startPos, endPos, Color.Orange, 0.0f);
|
||||
|
||||
isActive = false;
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
Vector2 barrelPos = Vector2.Zero;
|
||||
|
||||
RangedWeapon weapon = item.GetComponent<RangedWeapon>();
|
||||
if (weapon != null) barrelPos = weapon.BarrelPos;
|
||||
//RangedWeapon weapon = item.GetComponent<RangedWeapon>();
|
||||
//if (weapon != null) barrelPos = weapon.barrelPos;
|
||||
|
||||
return barrelPos;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
}
|
||||
|
||||
public override void SecondaryUse(Character character = null)
|
||||
public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (reload > 0.0f) return;
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Subsurface.Items.Components
|
||||
//}
|
||||
}
|
||||
|
||||
public override bool Use(Character character = null)
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (newNodePos!= Vector2.Zero && nodes.Count>0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ namespace Subsurface.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SecondaryUse(Character character = null)
|
||||
public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (nodes.Count > 1)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Subsurface.Items.Components
|
||||
//throwForce = ToolBox.GetAttributeFloat(element, "throwforce", 1.0f);
|
||||
}
|
||||
|
||||
public override bool Use(Character character = null)
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character == null) return false;
|
||||
if (!character.SecondaryKeyDown.State || throwing) return false;
|
||||
@@ -36,7 +36,7 @@ namespace Subsurface.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SecondaryUse(Character character = null)
|
||||
public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (throwing) return;
|
||||
throwPos = 0.25f;
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Subsurface.Items.Components
|
||||
//cam.OffsetAmount = prefab.OffsetOnSelected;
|
||||
}
|
||||
|
||||
public override void SecondaryUse(Character character = null)
|
||||
public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character == null) return;
|
||||
Vector2 centerPos = new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y);
|
||||
@@ -142,7 +142,7 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Use(Character character = null)
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (reload > 0.0f) return false;
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
//if (useSounds.Count() > 0) useSounds[Game1.localRandom.Next(useSounds.Count())].Play(1.0f, 800.0f, item.body.FarseerBody);
|
||||
|
||||
projectileComponent.Use();
|
||||
projectileComponent.Use(deltaTime);
|
||||
item.RemoveContained(projectile);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -119,13 +119,13 @@ namespace Subsurface.Items.Components
|
||||
for (int i = 0; i < limb.Length; i++)
|
||||
{
|
||||
if (limb[i] == null) continue;
|
||||
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker, limb[i]);
|
||||
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
||||
|
||||
if (containedItems == null) continue;
|
||||
for (int j = 0; j<containedItems.Length; j++)
|
||||
{
|
||||
if (containedItems[j] == null) continue;
|
||||
containedItems[j].ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker, limb[i]);
|
||||
containedItems[j].ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -308,18 +308,18 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, Limb limb = null)
|
||||
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null)
|
||||
{
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
foreach (StatusEffect effect in ic.statusEffects)
|
||||
{
|
||||
ApplyStatusEffect(effect, type, deltaTime, character, limb);
|
||||
ApplyStatusEffect(effect, type, deltaTime, character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyStatusEffect(StatusEffect effect, ActionType type, float deltaTime, Character character = null, Limb limb = null)
|
||||
public void ApplyStatusEffect(StatusEffect effect, ActionType type, float deltaTime, Character character = null)
|
||||
{
|
||||
if (condition == 0.0f) return;
|
||||
|
||||
@@ -358,7 +358,7 @@ namespace Subsurface
|
||||
//ApplyStatusEffect(effect, type, deltaTime, this);
|
||||
|
||||
if (effect.Targets.HasFlag(StatusEffect.Target.Character))
|
||||
effect.Apply(type, deltaTime, null, character, limb);
|
||||
effect.Apply(type, deltaTime, null, character);
|
||||
//ApplyStatusEffect(effect, type, deltaTime, null, character, limb);
|
||||
|
||||
if (container != null && effect.Targets.HasFlag(StatusEffect.Target.Parent))
|
||||
@@ -712,28 +712,28 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
public void Use(Character character = null)
|
||||
public void Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (condition == 0.0f) return;
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue;
|
||||
if (ic.Use(character))
|
||||
if (ic.Use(deltaTime, character))
|
||||
{
|
||||
ic.PlaySound(ActionType.OnUse, 1.0f, Position);
|
||||
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SecondaryUse(Character character = null)
|
||||
public void SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue;
|
||||
ic.SecondaryUse(character);
|
||||
ic.SecondaryUse(deltaTime, character);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Subsurface
|
||||
|
||||
if (physicsEnabled)
|
||||
{
|
||||
editingCharacter.Control(cam);
|
||||
editingCharacter.Control(1.0f, cam);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
dummyCharacter.ControlLocalPlayer(cam, false);
|
||||
dummyCharacter.Control(cam);
|
||||
dummyCharacter.Control((float)deltaTime, cam);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -57,6 +57,17 @@ namespace Subsurface
|
||||
|
||||
AmbientSoundManager.Update();
|
||||
|
||||
//Vector2 targetMovement = Vector2.Zero;
|
||||
//if (PlayerInput.KeyDown(Keys.I)) targetMovement.Y += 1.0f;
|
||||
//if (PlayerInput.KeyDown(Keys.K)) targetMovement.Y -= 1.0f;
|
||||
//if (PlayerInput.KeyDown(Keys.J)) targetMovement.X -= 1.0f;
|
||||
//if (PlayerInput.KeyDown(Keys.L)) targetMovement.X += 1.0f;
|
||||
|
||||
//foreach (MapEntity e in Structure.mapEntityList)
|
||||
//{
|
||||
// e.Move(targetMovement);
|
||||
//}
|
||||
|
||||
if (Game1.GameSession!=null) Game1.GameSession.Update((float)deltaTime);
|
||||
//EventManager.Update(gameTime);
|
||||
|
||||
|
||||
@@ -357,6 +357,12 @@
|
||||
<Content Include="Content\Items\idcard.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Tools\fueltank.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Tools\plasmacutter.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Weapons\harpoon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -400,10 +406,10 @@
|
||||
<Content Include="Content\Items\OxygenGenerator\item.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\OxygenTank\item.xml">
|
||||
<Content Include="Content\Items\Diving\item.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\OxygenTank\oxygentank.png">
|
||||
<Content Include="Content\Items\Diving\oxygentank.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\poweritems.xml">
|
||||
@@ -657,6 +663,7 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Content\Items\OxygenTank\" />
|
||||
<Folder Include="Content\SavedMaps\" />
|
||||
<Folder Include="Data\Saves\" />
|
||||
</ItemGroup>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user