|
class AnalyticsManagerClient |
|
{ |
|
static const int GEAR_COUNT = 3; |
|
static string m_FullGear[GEAR_COUNT] = {"Shoulder","Melee","Back"}; |
|
|
|
void RegisterEvents() |
|
{ |
|
ClientData.SyncEvent_OnEntityKilled.Insert(Event_OnEntityKilled); |
|
ClientData.SyncEvent_OnPlayerIgnitedFireplace.Insert(Event_OnPlayerIgnitedFireplace); |
|
} |
|
|
|
void UnregisterEvents() |
|
{ |
|
ClientData.SyncEvent_OnEntityKilled.Remove(Event_OnEntityKilled); |
|
ClientData.SyncEvent_OnPlayerIgnitedFireplace.Remove(Event_OnPlayerIgnitedFireplace); |
|
} |
|
|
|
|
|
|
|
|
|
void OnActionEat() |
|
{ |
|
Achievements.OnActionEat(); |
|
} |
|
|
|
|
|
|
|
|
|
void OnActionDrink() |
|
{ |
|
Achievements.OnActionDrink(); |
|
} |
|
|
|
|
|
|
|
|
|
void OnActionCookedSteak() |
|
{ |
|
Achievements.OnCookedSteak(); |
|
} |
|
|
|
|
|
|
|
|
|
void OnActionFinishedShaveSelf() |
|
{ |
|
Achievements.OnActionShave(); |
|
} |
|
|
|
|
|
|
|
|
|
void OnActionFinishedGutDeer() |
|
{ |
|
Achievements.OnActionGutDeer(); |
|
} |
|
|
|
|
|
|
|
|
|
void OnActionRestrain() |
|
{ |
|
Achievements.OnActionHandcuff(); |
|
} |
|
|
|
|
|
|
|
|
|
void OnActionBandageTarget() |
|
{ |
|
Achievements.OnActionMedsSurvivor(); |
|
} |
|
|
|
|
|
|
|
|
|
void OnItemAttachedAtPlayer(EntityAI item, string slot_name) |
|
{ |
|
bool weapon_present; |
|
bool melee_present; |
|
bool backpack_present; |
|
HumanInventory inventory; |
|
|
|
if ( GetDayZGame().GetGameState() != DayZGameState.IN_GAME ) |
|
{ |
|
return; |
|
} |
|
|
|
Man player = GetGame().GetPlayer(); |
|
if (!player) |
|
{ |
|
return; |
|
} |
|
|
|
inventory = player.GetHumanInventory(); |
|
|
|
if ( player && inventory ) |
|
{ |
|
for ( int i = 0; i < GEAR_COUNT; ++i ) |
|
{ |
|
int slot_id = InventorySlots.GetSlotIdFromString(m_FullGear[i]); |
|
EntityAI att_item = inventory.FindAttachment( slot_id ); |
|
|
|
if ( !att_item ) |
|
{ |
|
|
|
continue; |
|
} |
|
|
|
|
|
if (att_item.IsWeapon()) |
|
weapon_present = true; |
|
|
|
else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Melee"))) |
|
melee_present = true; |
|
|
|
else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Back"))) |
|
backpack_present = true; |
|
|
|
} |
|
|
|
|
|
att_item = inventory.GetEntityInHands(); |
|
if ( att_item ) |
|
{ |
|
|
|
if (att_item.IsWeapon()) |
|
weapon_present = true; |
|
|
|
else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Melee")) ) |
|
melee_present = true; |
|
|
|
else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Back"))) |
|
backpack_present = true; |
|
} |
|
|
|
if (weapon_present && melee_present && backpack_present) |
|
{ |
|
|
|
Achievements.OnEquippedFullGear(); |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
void Event_OnPlayerIgnitedFireplace( EFireIgniteType ignite_type ) |
|
{ |
|
switch ( ignite_type ) |
|
{ |
|
case EFireIgniteType.Matchbox: |
|
{ |
|
Achievements.OnActionIgniteMatchbox(); |
|
break; |
|
} |
|
case EFireIgniteType.Roadflare: |
|
{ |
|
Achievements.OnActionIgniteRoadflare(); |
|
break; |
|
} |
|
case EFireIgniteType.HandDrill: |
|
{ |
|
Achievements.OnActionIgniteDrill(); |
|
break; |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
void Event_OnEntityKilled(EntityAI victim, EntityAI killer, EntityAI source, bool is_headshot) |
|
{ |
|
if ( killer != null && killer.IsPlayer() && killer.GetID() == GetGame().GetPlayer().GetID() ) |
|
{ |
|
Achievements.OnPlayerKilled(victim, killer, source, is_headshot); |
|
} |
|
} |
|
} |