statuseffect setvalue, new diving suit sprite & character slowdown, welded door sprite

This commit is contained in:
Regalis
2015-09-26 00:41:43 +03:00
parent 53e729ea11
commit da00b083ed
21 changed files with 137 additions and 57 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -42,22 +42,27 @@
pickdistance="200"
price="200">
<Sprite texture ="DivingSuit.png" sourcerect="82,15,46,113" depth="0.5"/>
<Sprite texture ="DivingSuit.png" sourcerect="82,0,46,128" depth="0.55"/>
<Body width="37" height="113" density="5"/>
<Wearable slots="Head,Torso,Legs">
<sprite texture="DivingSuit.png" limb="Head" sourcerect="1,94,32,33" origin="0.5,0.5" depth="0.02"/>
<sprite texture="DivingSuit.png" limb="Torso" sourcerect="40,0,38,65" origin="0.5,0.33" depth="0.01"/>
<sprite texture="DivingSuit.png" limb="Torso" sourcerect="40,0,42,97" origin="0.5,0.55" depthlimb="Head" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="RightHand" sourcerect="21,0,18,50" origin="0.45,0.4"/>
<sprite texture="DivingSuit.png" limb="LeftHand" sourcerect="21,0,18,50" origin="0.45,0.4"/>
<sprite texture="DivingSuit.png" limb="RightHand" sourcerect="0,78,15,50" origin="0.45,0.4" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftHand" sourcerect="0,78,15,50" origin="0.45,0.4" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="RightArm" sourcerect="0,0,18,40" origin="0.5,0.4" depth="0.005"/>
<sprite texture="DivingSuit.png" limb="LeftArm" sourcerect="0,0,18,40" origin="0.5,0.4" depth="0.005"/>
<sprite texture="DivingSuit.png" limb="RightArm" sourcerect="0,0,19,43" origin="0.5,0.4" depth="0.005" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftArm" sourcerect="0,0,19,43" origin="0.5,0.4" depth="0.005" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="RightThigh" sourcerect="22,0,18,44" origin="0.5,0.5" depth="0.01" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftThigh" sourcerect="22,0,18,44" origin="0.5,0.5" depth="0.01" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="RightLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" targetnames="Oxygen Tank,human" Condition="-0.5" Oxygen="20.0"/>
<StatusEffect type="OnWearing" target="Character" PressureProtection="100.0"/>
<StatusEffect type="OnWearing" target="Character" PressureProtection="100.0" SpeedMultiplier="0.7" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/>
</Wearable>
<ItemContainer capacity="1" hideitems="true">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -4,10 +4,11 @@
linkable="true"
pickdistance="150.0">
<Sprite texture ="door.png" sourcerect="0,0,48,208" depth="0.8" origin="0.5,0.5"/>
<Sprite texture ="door.png" sourcerect="0,0,48,208" depth="0.01" origin="0.5,0.5"/>
<Door>
<Sprite texture ="door.png" sourcerect="80,0,19,208" depth="0.0" origin="0.5,0.0"/>
<Sprite texture ="door.png" sourcerect="80,0,19,208" depth="0.05" origin="0.5,0.0"/>
<WeldedSprite texture ="door.png" sourcerect="104,0,48,208" depth="0.0" origin="0.0,0.0"/>
</Door>
<AiTarget sightrange="5000.0"/>
@@ -26,10 +27,11 @@
linkable="true"
pickdistance="150.0">
<Sprite texture ="door.png" sourcerect="0,0,48,208" depth="0.8" origin="0.5,0.5"/>
<Sprite texture ="door.png" sourcerect="0,0,48,208" depth="0.01" origin="0.5,0.5"/>
<Door window="0,-18,10,89">
<Sprite texture ="door.png" sourcerect="56,0,19,208" depth="0.0" origin="0.5,0.0"/>
<WeldedSprite texture ="door.png" sourcerect="104,0,48,208" depth="0.0" origin="0.0,0.0"/>
</Door>
<AiTarget sightrange="5000.0"/>

View File

@@ -5,7 +5,7 @@
Tags="smallitem"
pickdistance="150">
<Sprite texture ="idcard.png" depth="0.8f"/>
<Sprite texture ="idcard.png" depth="0.8"/>
<Body width="16" height="16"/>

View File

@@ -134,10 +134,12 @@ namespace Subsurface
get { return selectedCharacter; }
}
//public AITarget AiTarget
//{
// get { return aiTarget; }
//}
private float lowPassMultiplier;
public float LowPassMultiplier
{
get { return lowPassMultiplier; }
set { lowPassMultiplier = MathHelper.Clamp(value, 0.0f, 1.0f); }
}
public float SoundRange
{
@@ -195,6 +197,12 @@ namespace Subsurface
bleeding = Math.Max(value, 0.0f);
}
}
public float SpeedMultiplier
{
get;
set;
}
public Item[] SelectedItems
{
@@ -296,7 +304,6 @@ namespace Subsurface
public Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
{
keys = new Key[Enum.GetNames(typeof(InputType)).Length];
keys[(int)InputType.Select] = new Key(false);
keys[(int)InputType.ActionHeld] = new Key(true);
@@ -319,6 +326,8 @@ namespace Subsurface
//blood = 100.0f;
aiTarget = new AITarget(this);
lowPassMultiplier = 1.0f;
Properties = ObjectProperty.GetProperties(this);
Info = characterInfo==null ? new CharacterInfo(file) : characterInfo;
@@ -499,6 +508,9 @@ namespace Subsurface
if (Math.Sign(targetMovement.X) == Math.Sign(AnimController.Dir) && GetInputState(InputType.Run))
targetMovement *= 3.0f;
targetMovement *= SpeedMultiplier;
SpeedMultiplier = 1.0f;
AnimController.TargetMovement = targetMovement;
AnimController.IsStanding = true;
@@ -740,6 +752,8 @@ namespace Subsurface
UpdateSightRange();
aiTarget.SoundRange = 0.0f;
lowPassMultiplier = MathHelper.Lerp(lowPassMultiplier, 1.0f, 0.1f);
if (needsAir)
{
if (AnimController.HeadInWater)

View File

@@ -414,11 +414,22 @@ namespace Subsurface
Vector2 origin = wearingItemSprite.Sprite.Origin;
if (body.Dir == -1.0f) origin.X = wearingItemSprite.Sprite.SourceRect.Width - origin.X;
float depth = sprite.Depth - 0.000001f;
if (wearingItemSprite.DepthLimb==LimbType.None)
{
Limb depthLimb = character.AnimController.GetLimb(wearingItemSprite.DepthLimb);
if (depthLimb!=null)
{
depth = depthLimb.sprite.Depth - 0.000001f;
}
}
wearingItemSprite.Sprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
color, origin,
-body.DrawRotation,
1.0f, spriteEffect, sprite.Depth - 0.000001f);
1.0f, spriteEffect, depth);
}
if (!GameMain.DebugDraw) return;

View File

@@ -21,6 +21,8 @@ namespace Subsurface
public string[] propertyNames;
private object[] propertyEffects;
private bool setValue;
private bool disableDeltaTime;
private string[] onContainingNames;
@@ -63,7 +65,6 @@ namespace Subsurface
IEnumerable<XAttribute> attributes = element.Attributes();
List<XAttribute> propertyAttributes = new List<XAttribute>();
disableDeltaTime = ToolBox.GetAttributeBool(element, "disabledeltatime", false);
foreach (XAttribute attribute in attributes)
{
@@ -96,6 +97,12 @@ namespace Subsurface
targetTypes |= (TargetType)Enum.Parse(typeof(TargetType), s, true);
}
break;
case "disabledeltatime":
disableDeltaTime = ToolBox.GetAttributeBool(attribute, false);
break;
case "setvalue":
setValue = ToolBox.GetAttributeBool(attribute, false);
break;
case "targetnames":
string[] names = attribute.Value.Split(',');
@@ -220,11 +227,15 @@ namespace Subsurface
Type type = value.GetType();
if (type == typeof(float))
{
property.TrySetValue((float)property.GetValue() + (float)value * deltaTime);
float floatValue = (float)value * deltaTime;
if (!setValue) floatValue += (float)property.GetValue();
property.TrySetValue(floatValue);
}
else if (type == typeof(int))
{
property.TrySetValue((int)property.GetValue() + (int)value * deltaTime);
int intValue = (int)((int)value * deltaTime);
if (!setValue) intValue += (int)property.GetValue();
property.TrySetValue(intValue);
}
else if (type == typeof(bool))
{

View File

@@ -98,7 +98,7 @@ namespace Subsurface.Items.Components
PhysicsBody body;
Sprite doorSprite;
Sprite doorSprite, weldedSprite;
public Door(Item item, XElement element)
: base(item, element)
@@ -108,9 +108,15 @@ namespace Subsurface.Items.Components
// isOpen = false;
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLower() != "sprite") continue;
doorSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile));
break;
switch (subElement.Name.ToString().ToLower())
{
case "sprite":
doorSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile));
break;
case "weldedsprite":
weldedSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile));
break;
}
}
doorRect = new Rectangle(
@@ -258,6 +264,11 @@ namespace Subsurface.Items.Components
//prefab.sprite.Draw(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
if (stuck>0.0f && weldedSprite!=null)
{
weldedSprite.Draw(spriteBatch, new Vector2(item.Rect.X, -item.Rect.Y), Color.White*(stuck/100.0f), 0.0f, 1.0f);
}
if (openState == 1.0f)
{
body.Enabled = false;
@@ -311,6 +322,8 @@ namespace Subsurface.Items.Components
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
{
if (isStuck) return;
if (connection.Name=="toggle")
{
isOpen = !isOpen;
@@ -318,7 +331,10 @@ namespace Subsurface.Items.Components
else if (connection.Name == "set_state")
{
isOpen = (signal!="0");
}
}
//opening a partially stuck door makes it less stuck
if (isOpen) stuck = MathHelper.Clamp(stuck-30.0f, 0.0f, 100.0f); ;
}
}
}

View File

@@ -59,10 +59,9 @@ namespace Subsurface.Items.Components
{
float hullPercentage = 0.0f;
if (hull1 != null) hullPercentage = (hull1.Volume / hull1.FullVolume) * 100.0f;
flowPercentage = ((float)targetLevel - hullPercentage);
FlowPercentage = ((float)targetLevel - hullPercentage) * 10.0f;
}
currPowerConsumption = powerConsumption * Math.Abs(flowPercentage / 100.0f);
if (voltage < minVoltage) return;
@@ -72,11 +71,8 @@ namespace Subsurface.Items.Components
float powerFactor = (currPowerConsumption==0.0f) ? 1.0f : voltage;
//flowPercentage = maxFlow * powerFactor;
float deltaVolume = 0.0f;
deltaVolume = (flowPercentage/100.0f) * maxFlow * powerFactor;
float deltaVolume = (flowPercentage/100.0f) * maxFlow * powerFactor;
hull1.Volume += deltaVolume;
if (hull1.Volume > hull1.FullVolume) hull1.Pressure += 0.5f;
@@ -171,7 +167,7 @@ namespace Subsurface.Items.Components
float tempTarget;
if (float.TryParse(signal, NumberStyles.Any, CultureInfo.InvariantCulture, out tempTarget))
{
targetLevel = MathHelper.Clamp(tempTarget, 0.0f, 100.0f);
targetLevel = MathHelper.Clamp((tempTarget+100.0f)/2.0f, 0.0f, 100.0f);
}
}

View File

@@ -152,7 +152,7 @@ namespace Subsurface.Items.Components
if (PlayerInput.LeftButtonDown())
{
targetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y);
TargetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y);
targetVelocity.Y = -targetVelocity.Y;
valueChanged = true;

View File

@@ -9,11 +9,14 @@ namespace Subsurface.Items.Components
{
public Sprite Sprite;
public bool HideLimb;
public LimbType DepthLimb;
public WearableSprite(Sprite sprite, bool hideLimb)
public WearableSprite(Sprite sprite, bool hideLimb, LimbType depthLimb = LimbType.None)
{
Sprite = sprite;
HideLimb = hideLimb;
DepthLimb = depthLimb;
}
}
@@ -31,8 +34,8 @@ namespace Subsurface.Items.Components
var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList();
int spriteCount = sprites.Count();
wearableSprite = new WearableSprite[spriteCount];
limbType = new LimbType[spriteCount];
limb = new Limb[spriteCount];
limbType = new LimbType[spriteCount];
limb = new Limb[spriteCount];
int i = 0;
foreach (XElement subElement in sprites)
@@ -53,11 +56,12 @@ namespace Subsurface.Items.Components
spritePath = Path.GetDirectoryName( item.Prefab.ConfigFile)+"/"+spritePath;
var sprite = new Sprite(subElement, "", spritePath);
wearableSprite[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false));
//sprite[i].origin = new Vector2(sourceRect.Width / 2.0f, sourceRect.Height / 2.0f);
wearableSprite[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false),
(LimbType)Enum.Parse(typeof(LimbType),
ToolBox.GetAttributeString(subElement, "depthlimb", "None"), true));
limbType[i] = (LimbType)Enum.Parse(typeof(LimbType),
ToolBox.GetAttributeString(subElement, "limb", "Head"));
ToolBox.GetAttributeString(subElement, "limb", "Head"), true);
i++;
}

View File

@@ -564,10 +564,10 @@ namespace Subsurface
{
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
if (isHighlighted) color = Color.Orange;
if (prefab.sprite!=null)
if (prefab.sprite != null)
{
if (body==null)
if (body == null)
{
prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
}
@@ -576,8 +576,7 @@ namespace Subsurface
body.Draw(spriteBatch, prefab.sprite, color);
}
}
foreach (ItemComponent component in components) component.Draw(spriteBatch, editing);
if (!editing || (body!=null && !body.Enabled))

View File

@@ -76,6 +76,8 @@ namespace Subsurface
element.Add(
new XAttribute("name", JoinedNames),
new XAttribute("type", type.ToString()));
if (!string.IsNullOrWhiteSpace("msg")) element.Add(new XAttribute("msg", Msg));
}
public static RelatedItem Load(XElement element)

View File

@@ -237,6 +237,7 @@ namespace Subsurface
soundIndex = AmbientSoundManager.flowSounds[index].Loop(soundIndex, soundVolume, Position, 2000.0f);
flowForce = Vector2.Zero;
lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, 0.05f);
if (open == 0.0f) return;
@@ -253,8 +254,6 @@ namespace Subsurface
UpdateRoomToRoom(deltaTime);
}
lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, 0.05f);
if (FlowForce.Length() > 150.0f && flowTargetHull != null && flowTargetHull.Volume < flowTargetHull.FullVolume)
{
//UpdateFlowForce();

View File

@@ -532,9 +532,9 @@ namespace Subsurface
stream.Dispose();
}
catch
catch (Exception e)
{
DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed!");
DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed! ("+e.Message+")");
return null;
}
}
@@ -545,9 +545,9 @@ namespace Subsurface
doc = XDocument.Load(file);
}
catch
catch (Exception e)
{
DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed!");
DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed! (" + e.Message + ")");
return null;
}
}

View File

@@ -117,7 +117,14 @@ namespace Subsurface.Particles
{
if (gap.isHorizontal != isHorizontal) continue;
if (gap.Open < 0.01f) continue;
if (gap.linkedTo[0]==currentHull && gap.linkedTo[1]!=null)
if (gap.linkedTo.Count==1)
{
if (!adjacentHulls.Contains(gap.linkedTo[0] as Hull))
{
adjacentHulls.Add(gap.linkedTo[0] as Hull);
}
}
else if (gap.linkedTo[0] == currentHull && gap.linkedTo[1] != null)
{
if (!adjacentHulls.Contains(gap.linkedTo[1] as Hull))
{

View File

@@ -283,7 +283,7 @@ namespace Subsurface
if (subList.CountChildren > 0 && subList.Selected == null) subList.Select(-1);
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(-1);
if (infoFrame.children.Find(c => c.UserData as string == "playyourself") == null)
if (playerFrame.children.Find(c => c.UserData as string == "playyourself") == null)
{
var playYourself = new GUITickBox(new Rectangle(-30, -30, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame);
playYourself.Selected = GameMain.Server.CharacterInfo != null;

View File

@@ -176,6 +176,8 @@ namespace Subsurface
lowpassHFGain = 0.2f;
}
lowpassHFGain *= Character.Controlled.LowPassMultiplier;
}
//how fast the sub is moving, scaled to 0.0 -> 1.0

View File

@@ -158,12 +158,21 @@ namespace Subsurface
return val;
}
public static bool GetAttributeBool(XElement element, string name, bool defaultValue)
{
if (element.Attribute(name) == null) return defaultValue;
var attribute = element.Attribute(name);
if (attribute == null) return defaultValue;
string val = element.Attribute(name).Value.ToLower().Trim();
string val = attribute.Value.ToLower().Trim();
return GetAttributeBool(attribute, defaultValue);
}
public static bool GetAttributeBool(XAttribute attribute, bool defaultValue)
{
if (attribute == null) return defaultValue;
string val = attribute.Value.ToLower().Trim();
if (val == "true")
{
return true;
@@ -174,10 +183,13 @@ namespace Subsurface
}
else
{
DebugConsole.ThrowError("Error in " + element + "! ''" + val + "'' is not a valid boolean value");
DebugConsole.ThrowError("Error in " + attribute.Value.ToString() + "! ''" + val + "'' is not a valid boolean value");
return false;
}
}
public static Vector2 GetAttributeVector2(XElement element, string name, Vector2 defaultValue)
{
if (element.Attribute(name) == null) return defaultValue;

Binary file not shown.