8,290
edits
No edit summary |
(modding -> script modding) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{Modding Info}}{{Modding Topic Prerequisites | Modding:C Sharp Scripting}} | |||
==Shifting Stats== | ==Shifting Stats== | ||
Line 33: | Line 31: | ||
<syntaxhighlight lang="csharp"> | <syntaxhighlight lang="csharp"> | ||
StatShifter.DefaultDisplayName = "camouflage"; | private void CheckCamouflage() | ||
StatShifter.SetStatShift(User, "DV", | { | ||
GameObject User = ParentObject.pPhysics.Equipped; | |||
if (User == null) return; | |||
if (User.pPhysics.CurrentCell != null) | |||
{ | |||
if (User.pPhysics.CurrentCell.HasObjectWithPart("PlantProperties")) | |||
{ | |||
StatShifter.DefaultDisplayName = "camouflage"; | |||
StatShifter.SetStatShift(User, "DV", Bonus); | |||
} | |||
else | |||
{ | |||
StatShifter.RemoveStatShifts(User); | |||
} | |||
} | |||
} | |||
public override bool FireEvent(Event E) | |||
{ | |||
if (E.ID == "EnteredCell") | |||
{ | |||
CheckCamouflage(); | |||
return true; | |||
} | |||
if (E.ID == "Equipped") | |||
{ | |||
GameObject GO = E.GetParameter<GameObject>("EquippingObject"); | |||
GO.RegisterPartEvent(this, "EnteredCell"); | |||
CheckCamouflage(); | |||
return true; | |||
} | |||
if (E.ID == "Unequipped") | |||
{ | |||
GameObject GO = E.GetParameter<GameObject>("UnequippingObject"); | |||
StatShifter.RemoveStatShifts(GO); | |||
GO.UnregisterPartEvent(this, "EnteredCell"); | |||
return true; | |||
} | |||
return base.FireEvent(E); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 40: | Line 79: | ||
{{Modding Navbox}} | {{Modding Navbox}} | ||
[[Category:Script Modding]] |