239 |
*/ |
*/ |
240 |
namespace |
namespace |
241 |
{ |
{ |
242 |
class MouseForce : public ForceField { |
class MouseForce { |
243 |
public: |
public: |
244 |
void set_force(V2 f) { force=f; } |
void set_force(V2 f) { force=f; } |
245 |
void add_force(V2 f) { force+=f; } |
void add_force(V2 f) { force+=f; } |
246 |
|
|
247 |
V2 get_force(Actor *a, V2 /*x*/, V2 /*v*/, double /*time*/) |
V2 get_force(Actor *a) { |
248 |
{ |
if (a->is_flying() || a->is_dead() || !a->int_attrib("mouseforce")) |
|
int iplayer=0; |
|
|
if (a->int_attrib("player", &iplayer) && iplayer != player::CurrentPlayer()) |
|
|
return V2(); |
|
|
|
|
|
if (a->is_flying() || a->is_dead() ) |
|
249 |
return V2(); |
return V2(); |
|
|
|
|
if (a->int_attrib("mouseforce")) |
|
|
return force; |
|
250 |
else |
else |
251 |
return V2(); |
return force; |
252 |
} |
} |
253 |
|
|
254 |
void tick(double /*dtime*/) { |
void tick(double /*dtime*/) { |
442 |
if (Floor *floor = GetFloor(p)) |
if (Floor *floor = GetFloor(p)) |
443 |
{ |
{ |
444 |
// Mouse force |
// Mouse force |
445 |
f += level->mouseforce.get_force(a,x,v,time)*floor->mousefactor(); |
f += floor->process_mouseforce(a, level->mouseforce.get_force(a)); |
446 |
|
|
447 |
// Friction |
// Friction |
448 |
double vv=length(v); |
double vv=length(v); |
462 |
} |
} |
463 |
|
|
464 |
// Electrostatic forces between actors. |
// Electrostatic forces between actors. |
|
V2 elforce; |
|
465 |
if (double q = a->get_charge()) { |
if (double q = a->get_charge()) { |
466 |
for (ActorList::iterator i=level->actorlist.begin(); |
for (ActorList::iterator i=level->actorlist.begin(); |
467 |
i != level->actorlist.end(); ++i) |
i != level->actorlist.end(); ++i) |