Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
acaly committed Jan 3, 2019
1 parent 69c532b commit 84d748f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Editor/Exporters/Player/SkillGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ private class SkillGeneratorEnv : GenerationEnvironment
private Dictionary<string, string> _GeneratedActorInit = new Dictionary<string, string>();
private HashSet<string> _GeneratedActorInitWithAB = new HashSet<string>();

private static int _NextInstanceId = 0;
private int _InstanceId = _NextInstanceId++;

public int GetActionID(string name)
{
if (name == null || name.Length == 0)
Expand Down Expand Up @@ -129,7 +132,7 @@ public void AddFunctionAlias(string newName, string oldName)

public string CreateNewFunctionName()
{
return "Alias_" + (nextEmptyId++).ToString();
return "Alias_" + _InstanceId + "_" + (nextEmptyId++).ToString();
}

public void GenerateAliasAssignment()
Expand Down
8 changes: 7 additions & 1 deletion Pat/Effects/BulletEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ public class BulletFollowingOwnerUpdateEffect : Effect

[XmlAttribute]
public bool IgnoreRotation { get; set; }

[XmlElement]
public bool ReleaseIfCheckFailed { get; set; }

Expand Down Expand Up @@ -319,6 +318,9 @@ public override void Run(Simulation.Actor actor)
(float)actor.Variables["SYS_follow_relx"].Value;
actor.Y = owner.Y + (float)actor.Variables["SYS_follow_rely"].Value;

actor.X += owner.VX;
actor.Y += owner.VY;

actor.InversedDirection = actor.Owner.InversedDirection;
if ((float)actor.Variables["SYS_follow_dir_p"].Value !=
(float)actor.Variables["SYS_follow_dir_s"].Value)
Expand Down Expand Up @@ -365,6 +367,7 @@ public override ILineObject Generate(GenerationEnvironment env)
}
if (cond != null)
{
cond = new BiOpExpr(new CustomCodeExpr("ownerActor != null"), cond, BiOpExpr.Op.And);
ret.Add(new ControlBlock(ControlBlockType.If, cond,
new ILineObject[] {
BulletEffectHelper.GenerateEnd(ReleaseIfCheckFailed, SegmentCheckFailed),
Expand All @@ -381,6 +384,9 @@ public override ILineObject Generate(GenerationEnvironment env)
ActorVariableHelper.GenerateGet("SYS_follow_rely"), BiOpExpr.Op.Add);
var dir = new BiOpExpr(dirChanged,
ActorVariableHelper.GenerateGet("SYS_follow_dir_s"), BiOpExpr.Op.Multiply);

x = new BiOpExpr(x, ownerActor.MakeIndex("vx"), BiOpExpr.Op.Add);
y = new BiOpExpr(y, ownerActor.MakeIndex("vy"), BiOpExpr.Op.Add);

var setRotation = ThisExpr.Instance.MakeIndex("rz").Assign(ownerActor.MakeIndex("rz")).Statement();
ret.AddRange(new ILineObject[] {
Expand Down
3 changes: 2 additions & 1 deletion Pat/Effects/CommonEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public override ILineObject Generate(GenerationEnvironment env)
else
{
_LastEnv = env;
_AliasName = null;
if (AdditionalBehaviors == null || AdditionalBehaviors.Count == 0)
{
funcName = env.GenerateActionAsActorInit(ActionName);
Expand All @@ -151,11 +152,11 @@ public override ILineObject Generate(GenerationEnvironment env)
}
});
}

if (_AliasName != null)
{
env.AddFunctionAlias(_AliasName, funcName);
}
_LastEnv = null;
}

var dir = ThisExpr.Instance.MakeIndex("direction");
Expand Down
14 changes: 10 additions & 4 deletions Pat/Effects/PointProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@ public override FramePoint GetPointForActor(Simulation.Actor actor)
var p = actor.CurrentFrame.Points[Index];

float scaleX = actor.ScaleX, scaleY = actor.ScaleY;

//TODO IMPORTANT check if point should be scaled

scaleX *= actor.CurrentFrame.ScaleX / 100.0f;
scaleY *= actor.CurrentFrame.ScaleY / 100.0f;

var x = scaleX * p.X;
var y = scaleY * p.Y;

var rx = x * Math.Cos(actor.Rotation) - y * Math.Sin(actor.Rotation);
var ry = y * Math.Cos(actor.Rotation) + x * Math.Sin(actor.Rotation);

//TODO should use float instead of int
return new FramePoint
{
X = (int)(actor.X + (AdjustSpeed ? actor.VX : 0) + scaleX * p.X),
Y = (int)(actor.Y + (AdjustSpeed ? actor.VY : 0) + scaleY * p.Y),
X = (int)(actor.X + rx + (AdjustSpeed ? actor.VX : 0)),
Y = (int)(actor.Y + ry + (AdjustSpeed ? actor.VY : 0)),
};
}

Expand Down

0 comments on commit 84d748f

Please sign in to comment.