forked from OpenRA/OpenRA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DropPodImpact.cs
77 lines (66 loc) · 1.97 KB
/
DropPodImpact.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Effects
{
public class DropPodImpact : IProjectile
{
readonly Target target;
readonly Animation entryAnimation;
readonly Player firedBy;
readonly string entryPalette;
readonly WeaponInfo weapon;
readonly WPos launchPos;
int weaponDelay;
bool impacted = false;
public DropPodImpact(Player firedBy, WeaponInfo weapon, World world, WPos launchPos, in Target target,
int delay, string entryEffect, string entrySequence, string entryPalette)
{
this.target = target;
this.firedBy = firedBy;
this.weapon = weapon;
this.entryPalette = entryPalette;
weaponDelay = delay;
this.launchPos = launchPos;
entryAnimation = new Animation(world, entryEffect);
entryAnimation.PlayThen(entrySequence, () => Finish(world));
if (weapon.Report != null && weapon.Report.Length > 0)
Game.Sound.Play(SoundType.World, weapon.Report, world, launchPos);
}
public void Tick(World world)
{
entryAnimation.Tick();
if (!impacted && weaponDelay-- <= 0)
{
var warheadArgs = new WarheadArgs
{
Weapon = weapon,
Source = target.CenterPosition,
SourceActor = firedBy.PlayerActor,
WeaponTarget = target
};
weapon.Impact(target, warheadArgs);
impacted = true;
}
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
return entryAnimation.Render(launchPos, wr.Palette(entryPalette));
}
void Finish(World world)
{
world.AddFrameEndTask(w => w.Remove(this));
}
}
}