You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.6 KiB
53 lines
1.6 KiB
using System.Collections.Generic; |
|
|
|
namespace ET |
|
{ |
|
[FriendClass(typeof(People))] |
|
public static class PeopleOperate |
|
{ |
|
public static int StopBehave(Unit unit, People people) |
|
{ |
|
if (people == null) |
|
{ |
|
return ErrorCode.ERR_PeopleNotFound; |
|
} |
|
|
|
var peopleBehave = people.GetBehaveType(); |
|
var targetId = people.GetTargetId(); |
|
switch (peopleBehave) |
|
{ |
|
case ConstBehaveType.BEHAVE_GATHER: |
|
case ConstBehaveType.BEHAVE_PREPARE_GATHER: |
|
GatherOperate.StopGather(unit, targetId, people.Id); |
|
break; |
|
case ConstBehaveType.BEHAVE_CONSTRUCT: |
|
case ConstBehaveType.BEHAVE_PREPARE_CONSTRUCT: |
|
ConstructOperate.StopConstruct(unit, targetId, people.Id); |
|
break; |
|
} |
|
|
|
people.SetBehaveType(ConstBehaveType.BEHAVE_IDLE); |
|
people.SetTargetId(0); |
|
return ErrorCode.ERR_Success; |
|
} |
|
|
|
public static int ChangeBehave(Unit unit, long peopleId,long targetId, int behaveType) |
|
{ |
|
var people = unit.GetComponent<PeopleComponent>().GetChild<People>(peopleId); |
|
if (people == null) |
|
{ |
|
return ErrorCode.ERR_PeopleNotFound; |
|
} |
|
|
|
var result = StopBehave(unit, people); |
|
if (result != ErrorCode.ERR_Success) |
|
{ |
|
return result; |
|
} |
|
|
|
people.TargetId = targetId; |
|
people.BehaveType = behaveType; |
|
return ErrorCode.ERR_Success; |
|
} |
|
} |
|
} |