switchable_base.c 715 B

12345678910111213141516171819202122232425262728293031323334
  1. class Switchable_Base extends ItemBase
  2. {
  3. override void OnWasAttached( EntityAI parent, int slot_id )
  4. {
  5. super.OnWasAttached( parent, slot_id );
  6. ItemBase parent_item;
  7. if ( Class.CastTo(parent_item,parent) )
  8. {
  9. parent_item.AddLightSourceItem(this);
  10. }
  11. }
  12. override void OnWasDetached( EntityAI parent, int slot_id )
  13. {
  14. super.OnWasDetached( parent, slot_id );
  15. ItemBase parent_item;
  16. if ( Class.CastTo(parent_item,parent) )
  17. {
  18. parent_item.RemoveLightSourceItem();
  19. }
  20. }
  21. override void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
  22. {
  23. super.EEItemLocationChanged(oldLoc, newLoc);
  24. if (GetLight())
  25. {
  26. GetLight().UpdateMode();
  27. }
  28. }
  29. }