Supercapacitor, shooting a turret wont use power if there isn't any ammo

This commit is contained in:
Regalis
2015-08-22 14:45:54 +03:00
parent d8904eaa56
commit 1e990784b2
6 changed files with 51 additions and 29 deletions

View File

@@ -41,7 +41,27 @@
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
<input name="power"/>
</ConnectionPanel>
</Item>
<Item
name="Supercapacitor"
linkable="true"
pickdistance="150">
<Sprite texture ="supercapacitor.png" depth="0.8"/>
<PowerContainer capacity="2000.0" maxrechargespeed="2000.0" maxoutput="2000.0" canbeselected = "true">
<GuiFrame rect="0,0,0.3,0.3" alignment="Center" color="0.0,0.0,0.0,0.8"/>
</PowerContainer>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power"/>
</ConnectionPanel>
</Item>
</Items>

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

View File

@@ -5,9 +5,9 @@
Tags="smallitem"
pickdistance="150">
<Sprite texture ="idcard.png" depth="0.5f"/>
<Sprite texture ="idcard.png" depth="0.8f"/>
<Body width="16" height="16" density="10"/>
<Body width="16" height="16"/>
<Pickable/>
</Item>

View File

@@ -121,8 +121,31 @@ namespace Subsurface.Items.Components
if (reload > 0.0f) return false;
Projectile projectileComponent = null;
//search for a projectile from linked containers
Item projectile = null;
foreach (MapEntity e in item.linkedTo)
{
Item container = e as Item;
if (container == null) continue;
ItemContainer containerComponent = container.GetComponent<ItemContainer>();
if (containerComponent == null) continue;
for (int i = 0; i < containerComponent.inventory.items.Length; i++)
{
if (containerComponent.inventory.items[i] == null) continue;
if ((projectileComponent = containerComponent.inventory.items[i].GetComponent<Projectile>()) != null)
{
projectile = containerComponent.inventory.items[i];
break;
}
}
if (projectileComponent != null) break;
}
if (projectile == null || projectileComponent == null) return false;
//currPowerConsumption = powerConsumption;
float availablePower = 0.0f;
//List<PowerContainer> batteries = new List<PowerContainer>();
@@ -147,31 +170,6 @@ namespace Subsurface.Items.Components
if (availablePower < currPowerConsumption) return false;
//search for a projectile from linked containers
Item projectile = null;
foreach (MapEntity e in item.linkedTo)
{
Item container = e as Item;
if (container == null) continue;
ItemContainer containerComponent = container.GetComponent<ItemContainer>();
if (containerComponent == null) continue;
for (int i = 0; i < containerComponent.inventory.items.Length; i++)
{
if (containerComponent.inventory.items[i] == null) continue;
if ((projectileComponent = containerComponent.inventory.items[i].GetComponent<Projectile>()) != null)
{
projectile = containerComponent.inventory.items[i];
break;
}
}
if (projectileComponent != null) break;
}
if (projectile == null || projectileComponent==null) return false;
projectile.body.ResetDynamics();
projectile.body.Enabled = true;
projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y)), -rotation);

View File

@@ -315,6 +315,9 @@
<Content Include="Content\Items\Electricity\lamp.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Electricity\supercapacitor.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Electricity\wifi.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -594,6 +597,7 @@
</Content>
<Content Include="Content\Items\Electricity\poweritems.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
<Content Include="Content\Items\Weapons\railgun.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

Binary file not shown.