Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Assets/Scripts/Functional Definitions/Abilities/InvertTractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public override void SetTier(int abilityTier)
if (abilityTier < 1) abilityTier = 1;
base.SetTier(abilityTier);
activeDuration = 5 * abilityTier;
cooldownDuration = 5 + abilityTier * 5;
}

protected override void Awake()
Expand All @@ -19,11 +20,11 @@ protected override void Awake()
}

/// <summary>
/// Returns the engine power to the original value
/// Disable invert tractor
/// </summary>
public override void Deactivate()
{
Core.tractorSwitched = false;
Core.invertTractors--;
if (Core is ShellCore core && !MasterNetworkAdapter.lettingServerDecide) core.SetTractorTarget(null);
base.Deactivate();
}
Expand All @@ -35,13 +36,12 @@ public override void ActivationCosmetic(Vector3 targetPos)
Execute();
}


/// <summary>
/// Increases core engine power to speed up the core
/// Invert tractor
/// </summary>
protected override void Execute()
{
Core.tractorSwitched = true;
Core.invertTractors++;
AudioManager.PlayClipByID("clip_buff", transform.position);
base.Execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ protected void FixedUpdate()
}
else if (dist > 2f)
{
if (!owner.tractorSwitched)
if (!owner.isTractorSwitched)
{
rigidbody.AddForce(dir.normalized * (dist - 2F) * rigidbody.mass * tractorStrength / Time.fixedDeltaTime);
}
else
{
owner.GetComponent<Rigidbody2D>().AddForce(-dir.normalized * (dist - 2F) *
rigidbody.mass * tractorStrength / Time.fixedDeltaTime);
var ownerRigbody = owner.GetComponent<Rigidbody2D>();
ownerRigbody.AddForce(-dir.normalized * (dist - 2F) * ownerRigbody.mass * tractorStrength / Time.fixedDeltaTime);
}
}
}
Expand All @@ -165,7 +165,7 @@ protected void LateUpdate()
private float auxillaryScaleY = 0.6F;
protected void TractorBeamUpdate()
{
lineRenderer.material.color = owner.tractorSwitched ? new Color32(255, 32, 255, 128) : new Color32(88, 239, 255, 128);
lineRenderer.material.color = owner.isTractorSwitched ? new Color32(255, 32, 255, 128) : new Color32(88, 239, 255, 128);
this.energyPickupTimer -= Time.fixedDeltaTime * this.energyPickupSpeed;
// Grab energy automatically after a while when the craft is not pulling something more important
if (energyEnabled && (!target) && (this.energyPickupTimer < 0) && !owner.IsInvisible && !owner.isAbsorbing)
Expand Down Expand Up @@ -209,7 +209,7 @@ protected void TractorBeamUpdate()
coreGlow.gameObject.SetActive(true);
targetGlow.gameObject.SetActive(true);
var x = auxillaryParticleSystem.GetComponentInChildren<ParticleSystem>().main;
x.startColor = new ParticleSystem.MinMaxGradient(owner.tractorSwitched ? new Color32(255, 32, 255, 128) : new Color32(88, 239, 255, 128));
x.startColor = new ParticleSystem.MinMaxGradient(owner.isTractorSwitched ? new Color32(255, 32, 255, 128) : new Color32(88, 239, 255, 128));
auxillaryParticleSystem.SetActive(true);
auxillaryParticleSystem.transform.position = Vector3.Lerp(transform.position, target.transform.position, 0.5F);
auxillaryParticleSystem.transform.localScale = new Vector3((target.transform.position - transform.position).magnitude/0.2F, auxillaryScaleY, 1);
Expand Down Expand Up @@ -262,7 +262,7 @@ public void SetTractorTarget(Draggable newTarget, bool fromClient = false, bool
lineRenderer.enabled = (newTarget != null);
}

if (target)
if (target && (!owner.isTractorSwitched || !target.GetComponent<Entity>()))
{
target.RemoveDrag();
}
Expand All @@ -277,7 +277,7 @@ public void SetTractorTarget(Draggable newTarget, bool fromClient = false, bool
}
}

if (target && ((MasterNetworkAdapter.mode != MasterNetworkAdapter.NetworkMode.Client && (!owner.tractorSwitched || !target.GetComponent<Entity>())) || fromServer))
if (target && ((MasterNetworkAdapter.mode != MasterNetworkAdapter.NetworkMode.Client && (!owner.isTractorSwitched || !target.GetComponent<Entity>())) || fromServer))
{
target.AddDrag();
}
Expand Down Expand Up @@ -314,7 +314,7 @@ private bool IsValidDraggableTarget(Draggable newTarget)
public static bool InvertTractorCheck(Entity owner, Draggable newTarget)
{
Entity requestedTarget = newTarget.gameObject.GetComponent<Entity>();
if (owner.tractorSwitched || !requestedTarget || (FactionManager.IsAllied(requestedTarget.faction, owner.faction) && (requestedTarget.isStandardTractorTarget)))
if (owner.isTractorSwitched || !requestedTarget || (FactionManager.IsAllied(requestedTarget.faction, owner.faction) && (requestedTarget.isStandardTractorTarget)))
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,20 @@ public float GetDamageFactor()

[HideInInspector]
public int absorptions = 0;
[HideInInspector]
public int invertTractors = 0;

public bool canUseAbilities = true;

public bool isAbsorbing // if true, all incoming damage is converted to energy
{
get { return absorptions > 0; }
}
public bool tractorSwitched = false;

public bool isTractorSwitched // if true, switch tractor
{
get { return invertTractors > 0; }
}

public SectorManager sectorMngr;
protected Entity lastDamagedBy;
Expand Down Expand Up @@ -753,6 +759,7 @@ public virtual void Rebuild()

stealths = 0;
absorptions = 0;
invertTractors = 0;

BuildEntity();
GetComponentInChildren<MinimapLockRotationScript>().Initialize(); // initialize the minimap dot
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/HUD Scripts/ReticleScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void Update()
// it's draggable if it's not an entity or it's a draggable entity with the same faction
if (draggable && (targSys.GetTarget().position - craft.transform.position).sqrMagnitude <= 400
&& (!targSys.GetTarget().GetComponent<Entity>()
|| FactionManager.IsAllied(targSys.GetTarget().GetComponent<Entity>().faction, craft.faction) || craft.tractorSwitched))
|| FactionManager.IsAllied(targSys.GetTarget().GetComponent<Entity>().faction, craft.faction) || craft.isTractorSwitched))
{
craft.SetTractorTarget((craft.GetTractorTarget() == draggable) ? null : draggable);
}
Expand Down